-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Show message when connection to the database is not possible #5346
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
base: master
Are you sure you want to change the base?
Conversation
src/invidious.cr
Outdated
rescue ex | ||
puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make the linter happy:
rescue ex | |
puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}" | |
rescue exc | |
puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vdfjvgbdkrfg
I should have checked the ameba docs, sorry :/
src/invidious.cr:65:1
[C] Naming/RescuedExceptionsVariableName: Disallowed variable name, use one of these instead: 'e', 'ex', 'exception', 'error'
> rescue exc
^
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
rescue exc | ||
puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rescue exc | |
puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}" | |
rescue e | |
puts "Failed to connect to PostgreSQL database: #{e.cause.try &.message}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change all rescue ex
from the source code to make the linter happy or just this part :?
ex
seems to be accepted 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops I didn't realize that lint also failed... It would be nice if the Github UI could indicate failures of unstable branches vs stable ones like the lint job.
Anyways the original error was because the ex variable ended up overshadowing the variable in this Kemal status code handler later on:
error 500 do |env, ex|
The fix is to change that ex
to something else rather than change the variable for the rescue block.
This gives a better message when something goes wrong on the database connection. May not be better for debugging purposes, but the error messages returned are from PostgreSQL and they are very self explanatory (I believe)