-
Notifications
You must be signed in to change notification settings - Fork 1
feat: implement guard support (#24) #80
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
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.
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
return await this._stringifyAsync(data) | ||
.catch(async error => this._stringifyAsync({ | ||
statusCode: 500, | ||
message: 'Internal Server Error', | ||
error: await this._toReadableError(error), | ||
})) | ||
.catch(async error => this._stringifyAsync({ | ||
statusCode: 500, | ||
message: 'Internal Server Error', | ||
error: await this._toReadableError(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.
[nitpick] Chaining two consecutive .catch calls on _stringifyAsync may hide errors rather than handling them explicitly. Consider refactoring this logic with a try-catch block for clearer and more reliable error handling.
return await this._stringifyAsync(data) | |
.catch(async error => this._stringifyAsync({ | |
statusCode: 500, | |
message: 'Internal Server Error', | |
error: await this._toReadableError(error), | |
})) | |
.catch(async error => this._stringifyAsync({ | |
statusCode: 500, | |
message: 'Internal Server Error', | |
error: await this._toReadableError(error), | |
})) | |
try { | |
return await this._stringifyAsync(data) | |
} catch (error) { | |
try { | |
return await this._stringifyAsync({ | |
statusCode: 500, | |
message: 'Internal Server Error', | |
error: await this._toReadableError(error), | |
}) | |
} catch (nestedError) { | |
return await this._stringifyAsync({ | |
statusCode: 500, | |
message: 'Internal Server Error', | |
error: await this._toReadableError(nestedError), | |
}) | |
} | |
} |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
const canActivate = await guard.canActivate(context) | ||
if (canActivate === true) | ||
continue | ||
return false |
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.
The guard execution does not include error handling; if guard.canActivate throws an exception, it could lead to unhandled errors. Consider wrapping this call in a try-catch block to provide a controlled failure response.
const canActivate = await guard.canActivate(context) | |
if (canActivate === true) | |
continue | |
return false | |
try { | |
const canActivate = await guard.canActivate(context) | |
if (canActivate === true) | |
continue | |
return false | |
} catch (error) { | |
// Log the error or handle it as needed | |
console.error('Error in guard.canActivate:', error) | |
return false | |
} |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
No description provided.