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

Include stack trace when sampling errors are surfaced #2326

Closed
amontanez24 opened this issue Dec 19, 2024 · 0 comments · Fixed by #2329
Closed

Include stack trace when sampling errors are surfaced #2326

amontanez24 opened this issue Dec 19, 2024 · 0 comments · Fixed by #2329
Labels
feature request Request for a new feature maintenance Tasks related to infrastructure & dependencies

Comments

@amontanez24
Copy link
Contributor

Problem Description

As a developer, I'd like to be able to see the stack trace of an error so I can figure out what went wrong and where to look.

We have a function that catches and surfaces errors with a better message during sampling.

def handle_sampling_error(output_file_path, sampling_error):
"""Handle sampling errors by printing a user-legible error and then raising.
Args:
output_file_path (str):
The output file path.
sampling_error:
The error to raise.
Side Effects:
The error will be raised.
"""
if 'Unable to sample any rows for the given conditions' in str(sampling_error):
raise sampling_error
error_msg = None
if output_file_path is not None:
error_msg = f'Error: Sampling terminated. Partial results are stored in {output_file_path}.'
else:
error_msg = (
'Error: Sampling terminated. No results were saved due to unspecified '
'"output_file_path".'
)
if error_msg:
raise type(sampling_error)(error_msg + '\n' + str(sampling_error))
raise sampling_error

The problem is that when we raise the new error, we're only including the original error message but not the stack trace. This makes it almost impossible to debug. Below is an example output
image

Expected behavior

Additional context

if error_msg:
raise type(sampling_error)(error_msg + '\n' + str(sampling_error))

The line above should be something like

raise type(sampling_error)(error_msg) from sampling_error
@amontanez24 amontanez24 added feature request Request for a new feature maintenance Tasks related to infrastructure & dependencies labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature maintenance Tasks related to infrastructure & dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant