-
Notifications
You must be signed in to change notification settings - Fork 60
A potential fix for messy error box when Error is KeyError #1932
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very annoying bug indeed. I tried to fix it in the past but hit a wall: currently the new error context messages are not affecting the error trace, your fix does affect it. Im not sure what is more important good error message or good error trace, but if you could solve it in a way both are optimized it will be much better.
Maybe the fix should be not to raise KeyError to begin with?
65522c8
to
061f86a
Compare
061f86a
to
ddead88
Compare
Hi @elronbandel , I changed to return an extension of KeyError that prints out its args not as a constant string, but obeying the \n -s. |
So what does the error trace look like now? is it of the original error? my suggestion was to wrap the problematic external code with: try:
# call to external code that raises key error
except KeyError as e:
raise RuntimeError("Key was not found: {e}") but this wrapping has to be write on top of the problematic code, so the error trace leads to the exact point of error. |
ddead88
to
659d395
Compare
Hi @elronbandel , I attached the full notebook for you to see both traces. Are these close enough? |
HI @elronbandel , I am not sure I understand whether you consider this "right on top of the problematic code,". |
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
cff8ba0
to
c3ce6b4
Compare
BEFORE:
error_box_main.pdf
AFTER:
error_box_fixed.pdf