Patch to rethrow exceptions as errors from json encode/decode