refactor: Refactored middlewares to use RequestError

Refactored middlewares to use RequestError rather than using
`try {...}catch (err){...}`. With this change it's possible to manage
all error details within one place.

Added:
- Added Sentry.captureException to Error Handler
This commit is contained in:
Hüseyin Berke Bütün
2022-12-22 01:42:02 +01:00
parent bd9041a62c
commit 6f5d7a831b
13 changed files with 156 additions and 199 deletions
+2
View File
@@ -176,6 +176,7 @@ const syncIntegrationsHelper = async ({
*/
const getIntegrationAuthRefreshHelper = async ({ integrationAuthId }: { integrationAuthId: string }) => {
let refreshToken;
//TODO: Refactor code to take advantage of using RequestError. It's possible to create new types of errors for more detailed errors
try {
const integrationAuth = await IntegrationAuth
.findById(integrationAuthId)
@@ -209,6 +210,7 @@ const syncIntegrationsHelper = async ({
*/
const getIntegrationAuthAccessHelper = async ({ integrationAuthId }: { integrationAuthId: string }) => {
let accessToken;
//TODO: Refactor code to take advantage of using RequestError. It's possible to create new types of errors for more detailed errors
try {
const integrationAuth = await IntegrationAuth
.findById(integrationAuthId)
+1
View File
@@ -21,6 +21,7 @@ const validateMembership = async ({
}) => {
let membership;
//TODO: Refactor code to take advantage of using RequestError. It's possible to create new types of errors for more detailed errors
try {
membership = await Membership.findOne({
user: userId,