-
Notifications
You must be signed in to change notification settings - Fork 333
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
Convert "Invalid source root" errors to UserErrors #1282
Conversation
src/init.ts
Outdated
// Handle the situation where init is called twice | ||
// for the same database in the same job. | ||
// Check if we need to re-throw the error as a UserError in order to avoid | ||
// counting this error towards our internal error budget. | ||
if ( |
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.
Time to extract these conditions into their own shouldReportAsUserError
helper function?
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.
sure
7c40d0f
to
7c11f80
Compare
Rebasing in order to pick up a fix in integration tests from #1281. |
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.
Looks good, minor suggestions only.
src/init.ts
Outdated
return new util.UserError( | ||
`Is the "init" action called twice in the same job? ${e.message}` | ||
); | ||
} else if ( |
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.
Don't need the else
since you're returning early.
src/init.ts
Outdated
e.message?.includes("Invalid source root") | ||
) { | ||
return new util.UserError(e.message); | ||
} else { |
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.
Similar, this can just be a final fall-through return statement.
7c11f80
to
e62ee58
Compare
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.
Just a question/suggestion, not approving yet because it'll probably be dismissed by another commit anyway.
* attributed to the user, otherwise the original error. | ||
*/ | ||
function processError(e: any): Error { | ||
if (!(e instanceof Error)) { |
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.
Just curious: when would e
not be an instanceof Error
if it was sent from the try/catch
block? Or is this just good practice in any error handling function?
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.
In javascript, you can "throw" anything. So you are not guaranteed that a catch clause is actually catching an Error
instance. In practice, you should only throw errors. Typescript is just being pedantic here, and so is this code.
befd353
to
9e044c5
Compare
This is an internal change. No changelog note required.
Merge / deployment checklist