diff options
author | Kosuke Shibata <56685224+shibaaaa@users.noreply.github.com> | 2023-09-14 09:25:06 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-10-03 16:13:18 +0900 |
commit | 2325e1cd81d721645ad600d93829604c13f6cbd8 (patch) | |
tree | f4b64f24b56240330d5ff2520dd3354fbd344a34 /lib/csv.rb | |
parent | 457971f4e243a76084d06ae840f4218b7a2062a3 (diff) |
[ruby/csv] Add CSV::InvalidEncodingError
(https://github.com/ruby/csv/pull/287)
To handle encoding errors in CSV parsing with the appropriate error
class
https://github.com/ruby/csv/commit/68b44887e5
Diffstat (limited to 'lib/csv.rb')
-rw-r--r-- | lib/csv.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index d4dc569b83..81fa99aa99 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -854,6 +854,15 @@ class CSV end end + # The error thrown when the parser encounters invalid encoding in CSV. + class InvalidEncodingError < MalformedCSVError + attr_reader :encoding + def initialize(encoding, line_number) + @encoding = encoding + super("Invalid byte sequence in #{encoding}", line_number) + end + end + # # A FieldInfo Struct contains details about a field's position in the data # source it was read from. CSV will pass this Struct to some blocks that make |