[dancer-users] JSON exception return values

Jeff Boes jeff at endpoint.com
Mon Oct 6 22:46:18 BST 2014

When one of my Dancer (1) JSON-enabled routes dies, I get an object back that looks like this:

   "exception" : "some text here",
   "error" : "some text here"

Recently, I accidentally added a "die" statement with a parameter that wasn't a scalar. (Spoiler: it was a hashref.) I
was surprised to see this:

   "exception" : {
      "state_iso_code" : "'(undef)' not a US state or province'",
      "address" : "blank"
   "error" : "HASH(0x731ce28)"

Woo, that's pretty cool, I thought. I can use that. But how the heck did I do that? I'd like to have a bit more control,
like supplying a general "your form failed" message instead of the "HASH()" stringified value.

I searched the code base, but as you may expect, "exception" and "error" are grep-proof strings to some extent.

Jeff Boes <><
jeff at endpoint.com

More information about the dancer-users mailing list