Skip to content
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

improve error message for unescape_string #21255

Merged
merged 1 commit into from
Apr 27, 2017

Conversation

pfitzseb
Copy link
Member

@pfitzseb pfitzseb commented Apr 2, 2017

Because

julia> unescape_string("\\U")
ERROR: ArgumentError: \x used with no following hex digits in "\\U"

just looks confusing.

@ararslan ararslan added the domain:strings "Strings!" label Apr 2, 2017
@kshyatt kshyatt added the domain:error handling Handling of exceptions by Julia or the user label Apr 2, 2017
@JeffBezanson JeffBezanson merged commit 711291a into JuliaLang:master Apr 27, 2017
@JeffBezanson
Copy link
Sponsor Member

This is fine, but in the future it's nice to post an example of what the error looks like after your change.

@pfitzseb
Copy link
Member Author

Sure thing, will do. Thanks for merging!

@@ -299,7 +299,8 @@ function unescape_string(io, s::AbstractString)
i = j
end
if k == 1
throw(ArgumentError("\\x used with no following hex digits in $(repr(s))"))
throw(ArgumentError("invalid $(m == 2 ? "hex (\\x)" :
"unicode (\\u)") escape sequence used in $(repr(s))"))
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to be this specific, why not go all the way and differentiate \u and \U correctly as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:error handling Handling of exceptions by Julia or the user domain:strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants