feat: deduct from redis new api schema
This commit is contained in:
@@ -2,9 +2,16 @@ import { RecaseError } from "../../../index.js";
|
||||
import { BalancesErrorCode } from "../codes/balancesErrCodes.js";
|
||||
|
||||
export class InsufficientBalanceError extends RecaseError {
|
||||
constructor(opts?: { message?: string }) {
|
||||
constructor(opts?: {
|
||||
message?: string;
|
||||
value: number;
|
||||
featureId?: string;
|
||||
eventName?: string;
|
||||
}) {
|
||||
super({
|
||||
message: opts?.message || "Insufficient balance",
|
||||
message:
|
||||
opts?.message ||
|
||||
`Insufficient balance to deduct ${opts?.value} from ${opts?.featureId ? `feature ${opts?.featureId}` : `event ${opts?.eventName}`}`,
|
||||
code: BalancesErrorCode.InsufficientBalance,
|
||||
statusCode: 400,
|
||||
});
|
||||
|
||||
13
shared/api/errors/classes/entityErrClasses.ts
Normal file
13
shared/api/errors/classes/entityErrClasses.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { RecaseError } from "../base/RecaseError.js";
|
||||
import { EntityErrorCode } from "../codes/entityErrCodes.js";
|
||||
|
||||
export class EntityNotFoundError extends RecaseError {
|
||||
constructor(opts: { entityId: string }) {
|
||||
super({
|
||||
message: `Entity ${opts.entityId} not found`,
|
||||
code: EntityErrorCode.EntityNotFound,
|
||||
statusCode: 404,
|
||||
});
|
||||
this.name = "EntityNotFoundError";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user