mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 08:28:22 +00:00
Add error handling
This commit is contained in:
@@ -288,7 +288,7 @@ export const pkiAcmeServiceFactory = ({
|
|||||||
|
|
||||||
await acmeOrderAuthDAL.insertMany(
|
await acmeOrderAuthDAL.insertMany(
|
||||||
authorizations.map((auth) => ({
|
authorizations.map((auth) => ({
|
||||||
orderId: order.id,
|
orderId: createdOrder.id,
|
||||||
authId: auth.id
|
authId: auth.id
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import fastifyPlugin from "fastify-plugin";
|
|||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import { ZodError } from "zod";
|
import { ZodError } from "zod";
|
||||||
|
|
||||||
|
import { AcmeError } from "@app/ee/services/pki-acme/pki-acme-errors";
|
||||||
import { getConfig } from "@app/lib/config/env";
|
import { getConfig } from "@app/lib/config/env";
|
||||||
import {
|
import {
|
||||||
BadRequestError,
|
BadRequestError,
|
||||||
@@ -242,6 +243,16 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
|
|||||||
error: "TokenError",
|
error: "TokenError",
|
||||||
message: errorMessage
|
message: errorMessage
|
||||||
});
|
});
|
||||||
|
} else if (error instanceof AcmeError) {
|
||||||
|
void res
|
||||||
|
.type("application/problem+json")
|
||||||
|
.status(error.status)
|
||||||
|
.send({
|
||||||
|
status: error.status,
|
||||||
|
type: `urn:ietf:params:acme:error:${error.type}`,
|
||||||
|
detail: error.detail
|
||||||
|
// TODO: add subproblems if they exist
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
void res.status(HttpStatusCodes.InternalServerError).send({
|
void res.status(HttpStatusCodes.InternalServerError).send({
|
||||||
reqId: req.id,
|
reqId: req.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user