Sha256: e1ca7518c4a000ea69643eb53d208970a2b0874fe0e5d6fb92f24699a699f018
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 Bytes
Contents
module Jersey::Extensions module ErrorHandler def self.registered(app) app.set :dump_errors, false app.set :raise_errors, false app.set :show_exceptions, false # APIS should always return meaningful standardized errors # with statuses that best match HTTP conventions # # Places nicely with Jersey::HTTP::Errors app.error do content_type(:json) e = env['sinatra.error'] # get status code from Jersey Errors if e.class.const_defined?(:STATUS_CODE) status(e.class::STATUS_CODE) else status(500) end json(error: { type: e.class.name.split('::').last, request_id: env['REQUEST_ID'], message: e.message, backtrace: e.backtrace }) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jersey-0.2.0 | lib/jersey/extensions/error_handler.rb |
jersey-0.1.0 | lib/jersey/extensions/error_handler.rb |