Skip to content

More helpful error message for pgf backend #4022

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

Merged
merged 3 commits into from
Jan 22, 2015

Conversation

nwin
Copy link
Contributor

@nwin nwin commented Jan 21, 2015

Makes the error message more helpful if subprocess fails with a file-not-found-error.

Makes the error message more helpful if subprocess fails with a file-not-found-error.
@tacaswell tacaswell added this to the v1.4.x milestone Jan 21, 2015
@tacaswell tacaswell changed the title More helpful error message for pgf backend More helpful error message for pgf backend [backport to 1.4.x] Jan 21, 2015
raise RuntimeError("Error starting process '%s'" % self.texcommand)
except OSError as e:
if e.errno == errno.ENOENT:
raise OSError(errno.ENOENT, "Latex command not found. "
Copy link
Member

Choose a reason for hiding this comment

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

Is there a good reason to not re-raise this as an RuntimeError? By changing the exception type we are breaking API (as there is probably user code which expects to catch RuntimeError here).

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the idea was to discriminate between the "command not found" and "command returned with error" case, so errors when running the latex process are propagated as RuntimeError, not finding the latex command is an OS or environment error. That distinction is a new "feature" if you would like to say so. I don't really know if this is to be considered as breaking the API, since the behaviour on error is neither defined nor documented anywhere.

@tacaswell
Copy link
Member

@pwuertz

@pwuertz
Copy link
Contributor

pwuertz commented Jan 21, 2015

I'm confused.. didn't I apply such a patch to master already? Can't find it though..

@pwuertz
Copy link
Contributor

pwuertz commented Jan 21, 2015

No wait, I was the one catching and re-raising the OSError as RuntimeError with an error string (#3158). Do you feel that these additional changes to the error string are necessary?

@nwin
Copy link
Contributor Author

nwin commented Jan 22, 2015

TLDR: I do not care which error type you want to have but I think it would be nice if we could provide a help if the cause of the error is almost certain and I'm happy to change my PR to RuntimeError.

Until “recently” (well F21 still ships an older version) it was an uncomprehensible uncatched error message and without googling stackoverflow I would not have any idea what as going on… http://stackoverflow.com/questions/20000427/matplotlib-pgf-oserror-no-such-file-or-directory-in-subprocess-py Because of that I also heavily doubt that anybody relies on the fact that the error is an RuntimeError.

Thus I thought it would be nice to discriminate between some random error an a specific error whose cause is known.

Actually I think that this is a issue in python itself. It is not helpful at all to raise an file-not-found error without mentioning the requested file command.

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.x Jan 22, 2015
@tacaswell tacaswell changed the title More helpful error message for pgf backend [backport to 1.4.x] More helpful error message for pgf backend Jan 22, 2015
@tacaswell
Copy link
Member

Fair enough, target 1.5.x (no backporting).

I assumed that the RuntimeError was intentional because it was converting an OSError.

Can you add a note in https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes I agree it seems pedantic, but I think it is worth doing.

@nwin
Copy link
Contributor Author

nwin commented Jan 22, 2015

I thought about it, converting to RuntimeError is probably a good idea because people will maybe catch an OSError to check if their (data) files are missing. Sorry for the discussion I'll change it. ;)

@pwuertz
Copy link
Contributor

pwuertz commented Jan 22, 2015

Thanks for this enhancement!

jenshnielsen added a commit that referenced this pull request Jan 22, 2015
More helpful error message for pgf backend
@jenshnielsen jenshnielsen merged commit 41efb46 into matplotlib:master Jan 22, 2015
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