Files
cfw-autumn/shared/api/errors/classes/productErrClasses.ts
2025-10-19 11:41:16 +01:00

31 lines
874 B
TypeScript

import { RecaseError } from "../base/RecaseError.js";
import { ProductErrorCode } from "../codes/productErrCodes.js";
/**
* Product not found error
*/
export class ProductNotFoundError extends RecaseError {
constructor(opts: { productId: string; version?: string | number }) {
super({
message: `Product ${opts.productId} ${opts.version ? ` (version ${opts.version})` : ""} not found`,
code: ProductErrorCode.ProductNotFound,
statusCode: 404,
});
this.name = "ProductNotFoundError";
}
}
/**
* Product already exists error
*/
export class ProductAlreadyExistsError extends RecaseError {
constructor(opts: { productId: string; message?: string }) {
super({
message: opts.message || `Product ${opts.productId} already exists`,
code: ProductErrorCode.ProductAlreadyExists,
statusCode: 400,
});
this.name = "ProductAlreadyExistsError";
}
}