-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More helpful usage guidance on errors #201
Comments
Ah, I closed your PR in #202 as I didn't quite understand the point of it, but with the context of using Still not entirely sure what to do with this, because anything I can think of results in a very long error and I'm not a huge fan of that either. I'm somewhat thinking that we need to extend the way error reporting in general is being done and split things out in a "concise message" and "usage guidance", but I'm not entirely sure what/how yet 🤔 This would be useful for quite a few error messages, not just this one. I'll retitle the issue to reflect this. |
The lexer and parser now always return a ParseError; the Error() method is mostly unchanged: toml: line 1 (last key "x.key"): newlines not allowed within inline tables This adds an Extended() method, which will add some context where the error occurred, similar to e.g. clang or the Rust compiler: toml: error: newlines not allowed within inline tables At line 1, column 18: 1 | x = [{ key = 42 # ^ And the ExtendedUsage() also adds some usage guidance (not always present): toml: error: newlines not allowed within inline tables At line 1, column 16: 1 | x = [{ key = 42 ^ Error help: Inline tables must always be on a single line: table = {key = 42, second = 43} It is invalid to split them over multiple lines like so: # INVALID table = { key = 42, second = 43 } Use regular for this: [table] key = 42 second = 43 The line/column information should now also always be correct, and a number of error message have been tweaked a bit. Fixes #158 Fixes #201 Fixes #217
The lexer and parser now always return a ParseError; the Error() method is mostly unchanged: toml: line 1 (last key "x.key"): newlines not allowed within inline tables This adds an Extended() method, which will add some context where the error occurred, similar to e.g. clang or the Rust compiler: toml: error: newlines not allowed within inline tables At line 1, column 18: 1 | x = [{ key = 42 # ^ And the ExtendedUsage() also adds some usage guidance (not always present): toml: error: newlines not allowed within inline tables At line 1, column 16: 1 | x = [{ key = 42 ^ Error help: Inline tables must always be on a single line: table = {key = 42, second = 43} It is invalid to split them over multiple lines like so: # INVALID table = { key = 42, second = 43 } Use regular for this: [table] key = 42 second = 43 The line/column information should now also always be correct, and a number of error message have been tweaked a bit. Fixes #201 Fixes #217
The lexer and parser now always return a ParseError; the Error() method is mostly unchanged: toml: line 1 (last key "x.key"): newlines not allowed within inline tables This adds an ErrorWithLocation() method, which will add some context where the error occurred, similar to e.g. clang or the Rust compiler: toml: error: newlines not allowed within inline tables At line 1, column 18: 1 | x = [{ key = 42 # ^ And the ErrorWithUsage() also adds some usage guidance (not always present): toml: error: newlines not allowed within inline tables At line 1, column 16: 1 | x = [{ key = 42 ^ Error help: Inline tables must always be on a single line: table = {key = 42, second = 43} It is invalid to split them over multiple lines like so: # INVALID table = { key = 42, second = 43 } Use regular for this: [table] key = 42 second = 43 The line/column information should now also always be correct, and a number of error message have been tweaked a bit. Fixes #201 Fixes #217
The lexer and parser now always return a ParseError; the Error() method is mostly unchanged: toml: line 1 (last key "x.key"): newlines not allowed within inline tables This adds an ErrorWithLocation() method, which will add some context where the error occurred, similar to e.g. clang or the Rust compiler: toml: error: newlines not allowed within inline tables At line 1, column 18: 1 | x = [{ key = 42 # ^ And the ErrorWithUsage() also adds some usage guidance (not always present): toml: error: newlines not allowed within inline tables At line 1, column 16: 1 | x = [{ key = 42 ^ Error help: Inline tables must always be on a single line: table = {key = 42, second = 43} It is invalid to split them over multiple lines like so: # INVALID table = { key = 42, second = 43 } Use regular for this: [table] key = 42 second = 43 The line/column information should now also always be correct, and a number of error message have been tweaked a bit. Fixes #201 Fixes #217
It would be nicer to give a more helpfull and easyer to understand error message if unescaped backslashes are causing a panic.
Cureent error message for
C:\Users\
expected eight hexadecimal digits after '\U', but got "C:\\Us
The text was updated successfully, but these errors were encountered: