Harden gameplay timing and map loading
This commit is contained in:
16
lib/service-error.ts
Normal file
16
lib/service-error.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export class ServiceError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly status = 503,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function checkServiceError(error: { message: string; code?: string } | null) {
|
||||
if (!error) return;
|
||||
if (error.code === "P0001") throw new Error(error.message);
|
||||
if (error.code === "PGRST116") throw new ServiceError("Record not found", 404);
|
||||
console.error("Supabase request failed:", error.code, error.message);
|
||||
throw new ServiceError("MineGeo could not reach its data service. Please try again.");
|
||||
}
|
||||
Reference in New Issue
Block a user