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

RFC: Improved error messages #4794

Closed
wants to merge 4 commits into from
Closed

RFC: Improved error messages #4794

wants to merge 4 commits into from

Conversation

davidssmith
Copy link
Contributor

I took a crack at improving more error messages. I also tweaked the formatting of them a bit. Now only the error message and the affected functions are red. Everything else is the normal color. This helps the important information stand out.

Still outstanding is the exception handling. Right now, exception messages are not being handled consistently, and it would take more extensive changes to make that happen, so I didn't touch them.

Let me know if this is the right direction.

See #4762 and #4744

@@ -160,7 +160,7 @@ function squeeze(A::AbstractArray, dims)
for i in 1:ndims(A)
if in(i,dims)
if size(A,i) != 1
error("squeezed dims must all be size 1")
error("Squeezed dims must all be size 1,")
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Why ,?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was experimenting with making the messages more grammatically consistent
with the backtrace that follows.

On Wed, Nov 13, 2013 at 2:41 AM, Ivar Nesje notifications@github.comwrote:

In base/abstractarray.jl:

@@ -160,7 +160,7 @@ function squeeze(A::AbstractArray, dims)
for i in 1:ndims(A)
if in(i,dims)
if size(A,i) != 1

  •            error("squeezed dims must all be size 1")
    
  •            error("Squeezed dims must all be size 1,")
    

Why ,


Reply to this email directly or view it on GitHubhttps://github.com//pull/4794/files#r7619890
.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally the punctation should be left to the error formatting apparatus, but I wanted to start small.

@timholy
Copy link
Sponsor Member

timholy commented Nov 13, 2013

+1 for this effort. I occasionally still scratch my head over some error messages.

@JeffBezanson
Copy link
Sponsor Member

I don't like the trailing commas at all. We also don't need to add function names to every error message, since they are printed in the backtrace.

@ivarne
Copy link
Sponsor Member

ivarne commented Nov 14, 2013

@JeffBezanson This PR removes function names from error messages.

@JeffBezanson
Copy link
Sponsor Member

That's odd; maybe the diff I saw was getting rendered wrong or something like that.

Anyway the commas are bad; there should not be any "required formatting" inside error messages or we are bound to forget it in some cases. A message should just describe the problem with no further ceremony. The code that presents error messages can take care of adding newlines etc. as necessary.

@timholy
Copy link
Sponsor Member

timholy commented Nov 14, 2013

If it's just a question of fixing up details, should this be reopened?

@davidssmith
Copy link
Contributor Author

I'm working on removing the commas from this patch.

On Thu, Nov 14, 2013 at 2:43 PM, Tim Holy notifications@github.com wrote:

If it's just a question of fixing up details, should this be reopened?


Reply to this email directly or view it on GitHubhttps://github.com//pull/4794#issuecomment-28521018
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants