Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Zachary Scott <[email protected]>
  • Loading branch information
hahmed and zzak committed May 17, 2021
1 parent b28711f commit 1b8ceee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Mysql2Adapter < AbstractMysqlAdapter
ER_BAD_DB_ERROR = 1049
ER_ACCESS_DENIED_ERROR = 1045
ER_CONN_HOST_ERROR = 2003
ER_UNKOWN_HOST_ERROR = 2005
ER_UNKNOWN_HOST_ERROR = 2005

ADAPTER_NAME = "Mysql2"

Expand All @@ -47,7 +47,7 @@ def new_client(config)
raise ActiveRecord::NoDatabaseError.db_error(config[:database])
elsif error.error_number == ConnectionAdapters::Mysql2Adapter::ER_ACCESS_DENIED_ERROR
raise ActiveRecord::DatabaseConnectionError.username_error(config[:username])
elsif [ConnectionAdapters::Mysql2Adapter::ER_CONN_HOST_ERROR, ConnectionAdapters::Mysql2Adapter::ER_UNKOWN_HOST_ERROR].include?(error.error_number)
elsif [ConnectionAdapters::Mysql2Adapter::ER_CONN_HOST_ERROR, ConnectionAdapters::Mysql2Adapter::ER_UNKNOWN_HOST_ERROR].include?(error.error_number)
raise ActiveRecord::DatabaseConnectionError.hostname_error(config[:host])
else
raise ActiveRecord::ConnectionNotEstablished, error.message
Expand Down
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ def db_error(db_name)
To resolve this issue:
- Not created a database for this app, or deleted it? You may need to create your database.
- Database name changed? Check your database.yml config has the correct database name.
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:\n\n bin/rails db:create
MSG
Expand All @@ -246,14 +246,14 @@ def initialize(message = nil)
class << self
def hostname_error(hostname)
DatabaseConnectionError.new(<<~MSG)
We are having an issue connecting with your hostname: #{hostname}.\n
Please check your database configuration or ensure there is a connection open to your hostname.
There is an issue connecting with your hostname: #{hostname}.\n
Please check your database configuration and ensure there is a valid connection to your database.
MSG
end

def username_error(username)
DatabaseConnectionError.new(<<~MSG)
We are having an issue connecting to your database with your username/password, username: #{username}.\n
There is an issue connecting to your database with your username/password, username: #{username}.\n
Please check your database configuration to ensure the username/password are valid.
MSG
end
Expand Down

0 comments on commit 1b8ceee

Please sign in to comment.