feat: add TallyNote local reimbursement ledger
TallyNote release / linux-x64 (push) Failing after 2m41s
TallyNote release / linux-x64 (push) Failing after 2m41s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import type { FastifyRequest } from "fastify";
|
||||
|
||||
export class AppError extends Error {
|
||||
constructor(
|
||||
public readonly statusCode: number,
|
||||
public readonly code: string,
|
||||
message: string,
|
||||
public readonly details?: unknown,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function errorPayload(request: FastifyRequest, error: AppError) {
|
||||
return {
|
||||
error: {
|
||||
code: error.code,
|
||||
message: error.message,
|
||||
requestId: request.id,
|
||||
...(error.details === undefined ? {} : { details: error.details }),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function notFound(message = "没有找到对应内容"): never {
|
||||
throw new AppError(404, "NOT_FOUND", message);
|
||||
}
|
||||
Reference in New Issue
Block a user