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

src: include error message when reporting failed R2 operations to sentry #82

Merged
merged 1 commit into from
Nov 19, 2023

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Nov 18, 2023

No description provided.

@@ -56,17 +56,21 @@ async function r2GetWithRetries(
key: string,
options?: R2GetOptions
): Promise<R2Object | null> {
let r2Error: unknown = undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let r2Error: unknown = undefined;
let r2Error: Error;

And no need to assign to undefined

Copy link
Member Author

Choose a reason for hiding this comment

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

In a try/catch block whatever was thrown has the type of undefined though?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm?

I mean that the default value of a let assignment will be undefined, and the type of err on catch in general is Error even if it might not during runtime

Copy link
Member Author

Choose a reason for hiding this comment

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

At least with the types I have the err type in a catch block is unknown, to get it to an Error we'd need to cast it

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to keep unknown then

@flakey5 flakey5 force-pushed the flakey5/20231118/retry-errors branch from a6b9c52 to 7f9ae9b Compare November 18, 2023 23:23
@flakey5 flakey5 merged commit 95ec685 into main Nov 19, 2023
3 checks passed
@ovflowd
Copy link
Member

ovflowd commented Nov 19, 2023

@flakey5 I saw you didnt remove the undefined assignments?

@flakey5 flakey5 deleted the flakey5/20231118/retry-errors branch November 19, 2023 18:43
@flakey5
Copy link
Member Author

flakey5 commented Nov 19, 2023

I saw you didnt remove the undefined assignments?

Agh, the second time within a 24 hour period of not saving a file before committing it. I'll remove them later on in another pr for some code cleanup

@ovflowd
Copy link
Member

ovflowd commented Nov 19, 2023

All good 🫶

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.

None yet

3 participants