-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Graphiti | ||
module Rails | ||
class ExceptionHandler < GraphitiErrors::ExceptionHandler | ||
# Since we're registering the errors with ActionDispatch, we can also use that | ||
# for getting the status code. | ||
def status_code(error) | ||
ActionDispatch.ExceptionWrapper.status_code_for_exception(error.class.name) | ||
end | ||
|
||
def detail(error) | ||
if status_code(error) >= 500 | ||
default_detail | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
# TODO: Remove this if we don't end up needing it | ||
module Graphiti | ||
module Rails | ||
class Railtie < ::Rails::Railtie | ||
config.action_dispatch.rescue_responses.merge!( | ||
# Graphiti::Errors::AdapterNotImplemented, | ||
# Graphiti::Errors::SideloadConfig, | ||
# Graphiti::Errors::Remote, | ||
# Graphiti::Errors::AroundCallbackProc, | ||
# Graphiti::Errors::RemoteWrite, | ||
# Graphiti::Errors::UnsupportedOperator, | ||
# Graphiti::Errors::UnwritableRelationship, | ||
# Graphiti::Errors::SingularSideload, | ||
# Graphiti::Errors::UnsupportedSort, | ||
# Graphiti::Errors::ExtraAttributeNotFound, | ||
# Graphiti::Errors::InvalidFilterValue, | ||
# Graphiti::Errors::MissingEnumAllowList, | ||
# Graphiti::Errors::InvalidLink, | ||
# Graphiti::Errors::SingularFilter, | ||
# Graphiti::Errors::Unlinkable, | ||
# Graphiti::Errors::SideloadParamsError, | ||
# Graphiti::Errors::SideloadQueryBuildingError, | ||
# Graphiti::Errors::SideloadAssignError, | ||
# Graphiti::Errors::AttributeError, | ||
# Graphiti::Errors::InvalidJSONArray, | ||
# Graphiti::Errors::InvalidEndpoint, | ||
# Graphiti::Errors::InvalidType, | ||
# Graphiti::Errors::ResourceEndpointConflict, | ||
# Graphiti::Errors::PolymorphicResourceChildNotFound, | ||
# Graphiti::Errors::ValidationError, | ||
# Graphiti::Errors::ImplicitFilterTypeMissing, | ||
# Graphiti::Errors::ImplicitSortTypeMissing, | ||
# Graphiti::Errors::TypecastFailed, | ||
# Graphiti::Errors::ModelNotFound, | ||
# Graphiti::Errors::TypeNotFound, | ||
# Graphiti::Errors::PolymorphicSideloadTypeNotFound, | ||
# Graphiti::Errors::PolymorphicSideloadChildNotFound, | ||
# Graphiti::Errors::MissingSideloadFilter, | ||
# Graphiti::Errors::MissingDependentFilter, | ||
# Graphiti::Errors::ResourceNotFound | ||
# Graphiti::Errors::UnsupportedPagination, | ||
# Graphiti::Errors::UnsupportedPageSize, | ||
# Graphiti::Errors::InvalidInclude, | ||
# Graphiti::Errors::StatNotFound, | ||
Graphiti::Errors::RecordNotFound => 404 | ||
# Graphiti::Errors::RequiredFilter | ||
) | ||
end | ||
end | ||
end |