Skip to content

Commit

Permalink
mysql2: Add Mysql2::Error
Browse files Browse the repository at this point in the history
Mysql2::Error is a class that is raised when an operation such as inserting a record fails.
https://github.com/brianmario/mysql2/blob/f6a9b68b42a51d1a370403f11eb88527dcb42dc6/lib/mysql2/error.rb
  • Loading branch information
euglena1215 committed Sep 16, 2024
1 parent e193a14 commit 09934f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gems/mysql2/0.5/_test/error_handling.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "mysql2"

begin
Mysql2::Client.new.query("INSERT INTO users (name) VALUES ('john')")
rescue Mysql2::Error => e
puts e.error_number
end
5 changes: 5 additions & 0 deletions gems/mysql2/0.5/error.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Mysql2
class Error < StandardError
attr_reader error_number: Integer
end
end

0 comments on commit 09934f1

Please sign in to comment.