Skip to content

Commit

Permalink
refactor: use constructor expression type
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed Jun 29, 2024
1 parent dd189ce commit d12601c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare namespace fastifyUnderPressure {
pressureHandler?: (request: FastifyRequest, reply: FastifyReply, type: string, value: number | undefined) => Promise<void> | void;
sampleInterval?: number;
exposeStatusRoute?: boolean | string | { routeOpts: object; routeSchemaOpts?: object; routeResponseSchemaOpts?: object; url?: string };
customError?: Error | ErrorConstructor;
customError?: Error | (new () => Error);
}

export const TYPE_EVENT_LOOP_DELAY = 'eventLoopDelay'
Expand Down
11 changes: 7 additions & 4 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ const server = fastify();
}
})

server.register(fastifyUnderPressure, {
customError: new Error('custom error message')
});
class CustomError extends Error {
constructor () {
super('Custom error message')
Error.captureStackTrace(this, CustomError)
}
}

server.register(fastifyUnderPressure, {
customError: Error
customError: CustomError
});
};

Expand Down

0 comments on commit d12601c

Please sign in to comment.