Merge branch 'api' of http://repository.trustie.net/xianbo/trustie2 into api
commit
29069c58ae
@ -0,0 +1,18 @@
|
|||||||
|
module Mobile
|
||||||
|
module Middleware
|
||||||
|
class ErrorHandler < Grape::Middleware::Base
|
||||||
|
def call!(env)
|
||||||
|
@env = env
|
||||||
|
begin
|
||||||
|
@app.call(@env)
|
||||||
|
rescue =>e
|
||||||
|
message = {status: 1, message: e.message }.to_json
|
||||||
|
status = 200
|
||||||
|
headers = { 'Content-Type' => content_type }
|
||||||
|
Rack::Response.new([message], status, headers).finish
|
||||||
|
# throw :error, :message => e.message || options[:default_message], :status => 500
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue