{"id":4083,"date":"2014-03-30T07:28:19","date_gmt":"2014-03-30T07:28:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-do-i-turn-all-rejections-into-custom-json-in-spray-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:28:19","modified_gmt":"2014-03-30T07:28:19","slug":"how-do-i-turn-all-rejections-into-custom-json-in-spray-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-do-i-turn-all-rejections-into-custom-json-in-spray-collection-of-common-programming-errors\/","title":{"rendered":"How do I turn all rejections into custom json in spray?-Collection of common programming errors"},"content":{"rendered":"<p>When spray (spray.io) produces a rejection, it responds with a string body. Since all my API clients will assume that my API only returns json, I&#8217;d like globally make every rejection a valid json object that conforms to our error object format. How can I make this happen?<\/p>\n<p>The error object format looks like this<\/p>\n<pre><code>{\n    'details' : 'Something happened in the app. boooo!',\n    'errorType' : 'Unknown'\n}\n<\/code><\/pre>\n<p>The errorType is my internal enum-style list of values like <code>UserNotFound<\/code> and <code>NeedPaidAccount<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When spray (spray.io) produces a rejection, it responds with a string body. Since all my API clients will assume that my API only returns json, I&#8217;d like globally make every rejection a valid json object that conforms to our error object format. How can I make this happen? The error object format looks like this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4083","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4083"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4083\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}