learning_ai_common_plat/services/growth-service/src/lib/errors.ts
saravanakumardb1 b94510aeb9 feat(services): add growth-service (invitations, referrals, promos)
- 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
2026-02-12 11:39:11 -08:00

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