-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve user feedback for errors during plot compilation (#3203)
* Improve user feedback for errors during plot compilation * Update release notes and fix flaky test * Fix pytest.raises usage and improve tests * Simplify comments for cleaner tracebacks
- Loading branch information
Showing
8 changed files
with
114 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Custom exceptions for the seaborn.objects interface. | ||
This is very lightweight, but it's a separate module to avoid circular imports. | ||
""" | ||
from __future__ import annotations | ||
|
||
|
||
class PlotSpecError(RuntimeError): | ||
""" | ||
Error class raised from seaborn.objects.Plot for compile-time failures. | ||
In the declarative Plot interface, exceptions may not be triggered immediately | ||
by bad user input (and validation at input time may not be possible). This class | ||
is used to signal that indirect dependency. It should be raised in an exception | ||
chain when compile-time operations fail with an error message providing useful | ||
context (e.g., scaling errors could specify the variable that failed.) | ||
""" | ||
@classmethod | ||
def _during(cls, step: str, var: str = "") -> PlotSpecError: | ||
""" | ||
Initialize the class to report the failure of a specific operation. | ||
""" | ||
message = [] | ||
if var: | ||
message.append(f"{step} failed for the `{var}` variable.") | ||
else: | ||
message.append(f"{step} failed.") | ||
message.append("See the traceback above for more information.") | ||
return cls(" ".join(message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters