44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { RecaseError } from "../base/RecaseError.js";
|
|
import { CusProductErrorCode } from "../codes/cusProductErrCodes.js";
|
|
|
|
/**
|
|
* Product not found error
|
|
*/
|
|
export class CusProductNotFoundError extends RecaseError {
|
|
constructor(opts: {
|
|
customerId: string;
|
|
productId: string;
|
|
entityId?: string;
|
|
}) {
|
|
const message = opts.entityId
|
|
? `Plan ${opts.productId} not found for entity ${opts.entityId}`
|
|
: `Plan ${opts.productId} not found for customer ${opts.customerId}`;
|
|
|
|
super({
|
|
message,
|
|
code: CusProductErrorCode.CustomerProductNotFound,
|
|
statusCode: 404,
|
|
});
|
|
this.name = "CustomerProductNotFoundError";
|
|
}
|
|
}
|
|
|
|
export class CusProductAlreadyExistsError extends RecaseError {
|
|
constructor(opts: {
|
|
productId: string;
|
|
customerId?: string;
|
|
entityId?: string;
|
|
}) {
|
|
const message = opts.entityId
|
|
? `Entity ${opts.entityId} already has plan ${opts.productId}`
|
|
: `Customer ${opts.customerId} already has plan ${opts.productId}`;
|
|
|
|
super({
|
|
message,
|
|
code: CusProductErrorCode.CustomerProductAlreadyExists,
|
|
statusCode: 400,
|
|
});
|
|
this.name = "CusProductAlreadyExistsError";
|
|
}
|
|
}
|