Skip to content

Commit 8e7a4a9

Browse files
committed
Adjust some connection errors to match what AR expects
1 parent 6e22be2 commit 8e7a4a9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/arjdbc/sqlite3/connection_methods.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22
ArJdbc::ConnectionMethods.module_eval do
33
def sqlite3_connection(config)
4+
raise ArgumentError, 'Configuration must not be empty' if config.blank?
5+
46
config = config.deep_dup
57
config[:adapter_spec] ||= ::ArJdbc::SQLite3
68
config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
@@ -18,7 +20,7 @@ def sqlite3_connection(config)
1820
parse_sqlite3_config!(config)
1921
rescue Errno::ENOENT => error
2022
if error.message.include?('No such file or directory')
21-
raise ActiveRecord::NoDatabaseError
23+
raise ActiveRecord::NoDatabaseError.new(connection_pool: ActiveRecord::ConnectionAdapters::NullPool.new)
2224
else
2325
raise
2426
end
@@ -50,7 +52,10 @@ def sqlite3_connection(config)
5052

5153
timeout = config[:timeout]
5254
if timeout && timeout.to_s !~ /\A\d+\Z/
53-
raise TypeError.new "Timeout must be nil or a number (got: #{timeout})."
55+
raise ActiveRecord::StatementInvalid.new(
56+
"TypeError: Timeout must be nil or a number (got: #{timeout}).",
57+
connection_pool: ActiveRecord::ConnectionAdapters::NullPool.new
58+
)
5459
end
5560

5661
options = config[:properties]

0 commit comments

Comments
 (0)