23 lines
485 B
TypeScript
23 lines
485 B
TypeScript
export const managePb404 = async <T>(
|
|
dbFunc: () => Promise<T>
|
|
): Promise<T | null> => {
|
|
try {
|
|
return await dbFunc()
|
|
} catch (err: any) {
|
|
if (err?.message === "The requested resource wasn't found.") {
|
|
return null
|
|
} else throw err
|
|
}
|
|
}
|
|
|
|
export const managePbError = async <T>(
|
|
dbFunc: () => Promise<T>
|
|
): Promise<T | null> => {
|
|
try {
|
|
return await dbFunc()
|
|
} catch (err: any) {
|
|
console.log("🚀 ~ managePbError ~ err:", err)
|
|
return null
|
|
}
|
|
}
|