Skip to content

handle-exception raises exception #289

@wpeers

Description

@wpeers

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

Metadata

Metadata

Labels

next-releaseSelected to be included in next release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions