BetterErrors / BetterErrors/better_errors

ignoring JSON

Open
#247 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
6.9k
Forks
430
PR merge metrics
No merged PRs in 30d

Description

This is probably a strange request...

I want use Better Errors for HTML requests in dev. If the request is JSON, whether dev or production, I want to emit a collection+JSON error.

Since I'm using Rails, I would love to handle this at the ApplicationController level. I see that Better Errors is hooked in at the rack level, so I suspect I can't use something like

```
def handle_exception( exception )
respond_to do |format|
format.html do
if( APP_CONFIG[:show_stacktrace] )
render :text => BetterError.for( exception ).to_html
else
render :file => 'public/404.html'
end
end
format.json { render :json => ExceptionEndpoint.new(exception).to_json }
end
end
```

FWIW, ExceptionEndpoint isn't going to expose anything sensitive.

Since this is a rack app, though, I'm thinking I'll have to hook in some other way. Any direction would be appreciated.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.