Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

avoiding the use of the StandardError exception #331

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

Open
MaximilianoGarciaRoe wants to merge 1 commit into rubocop:master
base: master
Choose a base branch
Loading
from MaximilianoGarciaRoe:master
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.adoc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,44 @@ render status: :forbidden
...
----

=== Error Message [[http-status-code-symbols]]

It is recommended to avoid using the StandardError exception when rendering error messages in the code, as this may capture an unintended and controlled error.
Instead, it is suggested to capture specific errors or send a customized standard error message.
This ensures more accurate and effective exception handling in the program.

[source,ruby]
----
# bad
...
rescue StandardError => e
render json: {error_msg: e.message}
end
...

# bad - usign in flash message
...
rescue StandardError => e
flash[:error] = e.message
end
...


# good
...
rescue StandardError => e
render json: {error_msg: 'Error in the application'}
end
...

# good
...
rescue ParticularError => e
render json: {error_msg: e.message}
end
...
----

== Models

=== Model Classes [[model-classes]]
Expand Down

AltStyle によって変換されたページ (->オリジナル) /