mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 20:26:44 +00:00
fix: improve project error handling
This commit is contained in:
@@ -191,6 +191,10 @@ export const projectDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
return project;
|
return project;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof NotFoundError) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
throw new DatabaseError({ error, name: "Find all projects" });
|
throw new DatabaseError({ error, name: "Find all projects" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -240,6 +244,10 @@ export const projectDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
return project;
|
return project;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof NotFoundError || error instanceof UnauthorizedError) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
throw new DatabaseError({ error, name: "Find project by slug" });
|
throw new DatabaseError({ error, name: "Find project by slug" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -260,7 +268,7 @@ export const projectDALFactory = (db: TDbClient) => {
|
|||||||
}
|
}
|
||||||
throw new BadRequestError({ message: "Invalid filter type" });
|
throw new BadRequestError({ message: "Invalid filter type" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof BadRequestError) {
|
if (error instanceof BadRequestError || error instanceof NotFoundError || error instanceof UnauthorizedError) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
throw new DatabaseError({ error, name: `Failed to find project by ${filter.type}` });
|
throw new DatabaseError({ error, name: `Failed to find project by ${filter.type}` });
|
||||||
|
|||||||
Reference in New Issue
Block a user