Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle-exception raises exception #289

Open
wpeers opened this issue Sep 7, 2017 · 1 comment
Open

handle-exception raises exception #289

wpeers opened this issue Sep 7, 2017 · 1 comment
Assignees
Labels
next-release Selected to be included in next release

Comments

@wpeers
Copy link

wpeers commented Sep 7, 2017

Hi

When I try to return the Exception message of an exception thrown in a handler via handle-exception, then the server raises an Exception of it's own and returns that one.

java.lang.IllegalArgumentException: No method in multimethod 'render-map-generic' for dispatch value: null
	at clojure.lang.MultiFn.getFn(MultiFn.java:156)
	at clojure.lang.MultiFn.invoke(MultiFn.java:233)
	at liberator.representation$fn__8776.invokeStatic(representation.clj:203)
	at liberator.representation$fn__8776.invoke(representation.clj:192)
	at liberator.representation$fn__8574$G__8569__8581.invoke(representation.clj:16)
	at liberator.core$fn__9066.invokeStatic(core.clj:575)
	at liberator.core$fn__9066.invoke(core.clj:574)
	at liberator.core$run_handler.invokeStatic(core.clj:178)
	at liberator.core$run_handler.invoke(core.clj:130)
	at liberator.core$handle_exception.invokeStatic(core.clj:503)
	at liberator.core$handle_exception.invoke(core.clj:503)
	at liberator.core$decide.invokeStatic(core.clj:88)
	at liberator.core$decide.invoke(core.clj:73)

(def resource-defaults
  {:available-media-types ["application/json"]
   :handle-exception      (fn [ctx] {:error (:exception ctx)})

(defresource name
  resource-defaults
  :handle-ok (fn [ctx] (throw (Exception. "error-msg"))))

Expected return body to be:

 { "error": "error-msg"}

but got:

No method in multimethod 'render-map-generic' for dispatch value: null

Seems related to this but I'm unable to fix as handle-exception seems to bypass all other decision points and ignore the defined media-type "application/json"

tested with liberator 0.15.1

@dmichulke
Copy link

I had the same problem until I realized that there was an error in my handle-exception function that caused another exception.

@ordnungswidrig ordnungswidrig self-assigned this Jan 14, 2019
@ordnungswidrig ordnungswidrig added the next-release Selected to be included in next release label Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-release Selected to be included in next release
Projects
None yet
Development

No branches or pull requests

3 participants