egg_server/utils/pbTools.ts
zhaoyingbo 6e65581bbf
All checks were successful
Egg CI/CD / build-image (push) Successful in 32s
Egg CI/CD / deploy (push) Successful in 37s
feat: 接入lint 和 husky
2024-07-25 01:48:22 +00:00

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
}
}