Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't attempt to create exception classes #134

Merged
merged 1 commit into from Jun 16, 2015

Conversation

benlovell
Copy link
Collaborator

This resolves #126 by not attempting to create exception classes. A
couple of points no less:

  1. The ActiveRecord specific exceptions are loaded and merged when
    its railtie is loaded. Our tests do not load ActiveRecord so while
    they don't exist in our context, they will be around in your garden
    variety rails application.
  2. We essentially replicate what the ExceptionWrapper was doing for
    us, but by leveraging Rack::Utils.status_code we avoid the need to
    create an instance of the actual exception class. Thus avoiding the
    problems experienced creating exceptions that expect initializer
    arguments.

This resolves #126 by not attempting to create exception classes. A
couple of points no less:

1. The `ActiveRecord` specific exceptions _are_ loaded and merged when
its railtie is loaded. Our tests do not load `ActiveRecord` so while
they don't exist in our context, they _will_ be around in your garden
variety rails application.
2. We essentially replicate what the `ExceptionWrapper` was doing for
us, but by leveraging `Rack::Utils.status_code` we avoid the need to
create an instance of the actual exception class. Thus avoiding the
problems experienced creating exceptions that expect initializer
arguments.
@pxlpnk
Copy link
Collaborator

pxlpnk commented Jun 16, 2015

Looks, good. I was afraid that one needs to load 2/3 of rails for this. LGTM

benlovell added a commit that referenced this pull request Jun 16, 2015
Don't attempt to create exception classes
@benlovell benlovell merged commit 4f6841f into master Jun 16, 2015
@benlovell benlovell deleted the 126-exception-status-codes-fix branch June 16, 2015 12:22
@benlovell
Copy link
Collaborator Author

<3 cutting a release.

@pxlpnk
Copy link
Collaborator

pxlpnk commented Jun 16, 2015

\o/! Thank you so much @benlovell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants