Project

General

Profile

Actions

Feature #20210

closed

Invalid source encoding raises ArgumentError, not SyntaxError

Added by kddnewton (Kevin Newton) 4 months ago. Updated 3 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:116435]

Description

I was hoping we could change the error that is raised when an invalid source encoding is found from an ArgumentError to a SyntaxError.

First let me say, if this isn't possible for backward compatibility, I understand. Please do not take this as me not caring about backward compatibility.

Right now, if you have the script # encoding: foo\n"bar", it will raise an ArgumentError, not a SyntaxError. If there are other syntax errors in the file, there's no way to concat them together to give feedback to the user. If a user wants to consistently handle the errors coming back from a parse, they currently have to rescue ArgumentError and SyntaxError.

Ideally it would all be SyntaxError, so we could handle them consistently and append all errors together.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0