Files
cfw-autumn/shared/api/errors/classes/productErrClasses.ts
2025-12-08 20:27:44 +00:00

31 lines
873 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";
}
}