- Copied as-is from learning_voice_ai_agent/services/growth-service - 33 tests passing (vitest) - Fastify 5 + Cosmos DB + Stripe + Zod - Modules: invitations, referrals, promos - Port 4001
35 lines
713 B
TypeScript
35 lines
713 B
TypeScript
/**
|
|
* Typed service errors for consistent HTTP error responses.
|
|
*/
|
|
|
|
export class ServiceError extends Error {
|
|
constructor(
|
|
public statusCode: number,
|
|
message: string,
|
|
) {
|
|
super(message);
|
|
this.name = "ServiceError";
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends ServiceError {
|
|
constructor(message = "Not found") {
|
|
super(404, message);
|
|
this.name = "NotFoundError";
|
|
}
|
|
}
|
|
|
|
export class BadRequestError extends ServiceError {
|
|
constructor(message = "Bad request") {
|
|
super(400, message);
|
|
this.name = "BadRequestError";
|
|
}
|
|
}
|
|
|
|
export class ForbiddenError extends ServiceError {
|
|
constructor(message = "Forbidden") {
|
|
super(403, message);
|
|
this.name = "ForbiddenError";
|
|
}
|
|
}
|