Skip to content

Commit 9e1cc70

Browse files
committed
Pass through non-JSON api errors
This fixes a small 🐛 where all errors seem to originate from the gem. This is because we were catching, then re-raising, errors which came from non-JSON api endpoints; effectively all parts of the application. This changes that behavior so that we are just a noop middleware for non-JSON api endpoints. This means if they raise an error, we won't catch it, and the error will appear as coming from it's original source.
1 parent ddabc71 commit 9e1cc70

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/kracken/json_api/public_exceptions.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ def initialize(app)
77
end
88

99
def call(env)
10-
app.call(env)
10+
if JsonApi.has_path?(JsonApi::Request.new(env))
11+
capture_error(env)
12+
else
13+
@app.call(env)
14+
end
15+
end
16+
17+
def capture_error(env)
18+
@app.call(env)
1119
rescue Exception => exception
12-
raise exception unless JsonApi.has_path?(JsonApi::Request.new(env))
1320
render_json_error(ExceptionWrapper.new(env, exception))
1421
end
1522

0 commit comments

Comments
 (0)