File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
plugins/node/opentelemetry-instrumentation-fastify Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import type {
2727 FastifyInstance ,
2828 FastifyRequest ,
2929 FastifyReply ,
30+ FastifyErrorCodes ,
3031} from 'fastify' ;
3132import { hooksNamesToWrap } from './constants' ;
3233import {
@@ -185,6 +186,7 @@ export class FastifyInstrumentation extends InstrumentationBase<FastifyInstrumen
185186
186187 private _patchConstructor ( moduleExports : {
187188 fastify : ( ) => FastifyInstance ;
189+ errorCodes : FastifyErrorCodes | undefined ;
188190 } ) : ( ) => FastifyInstance {
189191 const instrumentation = this ;
190192
@@ -198,6 +200,9 @@ export class FastifyInstrumentation extends InstrumentationBase<FastifyInstrumen
198200 return app ;
199201 }
200202
203+ if ( moduleExports . errorCodes !== undefined ) {
204+ fastify . errorCodes = moduleExports . errorCodes ;
205+ }
201206 fastify . fastify = fastify ;
202207 fastify . default = fastify ;
203208 return fastify ;
Original file line number Diff line number Diff line change @@ -560,4 +560,15 @@ describe('fastify', () => {
560560 } ,
561561 } ) ;
562562 } ) ;
563+
564+ it ( 'should expose errorCodes' , async function ( ) {
565+ // errorCodes was added in v4.8.0
566+ // ref: https://github.com/fastify/fastify/compare/v4.7.0...v4.8.0
567+ if ( semver . lt ( fastifyVersion , '4.8.0' ) ) {
568+ this . skip ( ) ;
569+ }
570+ assert . ok ( Fastify . errorCodes ) ;
571+ assert . strictEqual ( typeof Fastify . errorCodes , 'object' ) ;
572+ assert . ok ( 'FST_ERR_NOT_FOUND' in Fastify . errorCodes ) ;
573+ } ) ;
563574} ) ;
You can’t perform that action at this time.
0 commit comments