Skip to content
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
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