Skip to content

Commit

Permalink
Merge pull request #2781 from Infisical/daniel/project-slug-500-error
Browse files Browse the repository at this point in the history
fix: improve project DAL error handling
  • Loading branch information
maidul98 authored Nov 25, 2024
2 parents a692148 + 2b977ee commit 71c9c0f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/src/services/project/project-dal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ export const projectDALFactory = (db: TDbClient) => {

return project;
} catch (error) {
if (error instanceof NotFoundError) {
throw error;
}

throw new DatabaseError({ error, name: "Find all projects" });
}
};
Expand Down Expand Up @@ -240,6 +244,10 @@ export const projectDALFactory = (db: TDbClient) => {

return project;
} catch (error) {
if (error instanceof NotFoundError || error instanceof UnauthorizedError) {
throw error;
}

throw new DatabaseError({ error, name: "Find project by slug" });
}
};
Expand All @@ -260,7 +268,7 @@ export const projectDALFactory = (db: TDbClient) => {
}
throw new BadRequestError({ message: "Invalid filter type" });
} catch (error) {
if (error instanceof BadRequestError) {
if (error instanceof BadRequestError || error instanceof NotFoundError || error instanceof UnauthorizedError) {
throw error;
}
throw new DatabaseError({ error, name: `Failed to find project by ${filter.type}` });
Expand Down

0 comments on commit 71c9c0f

Please sign in to comment.