@@ -117,6 +117,7 @@ interface APIRequestError {
117117 status : number
118118 message : string
119119 details ?: string [ ]
120+ additionalInfo ?: Record < string , unknown >
120121}
121122
122123function sofieAPIRequest < API , Params , Body , Response > (
@@ -133,6 +134,7 @@ function sofieAPIRequest<API, Params, Body, Response>(
133134 ) => Promise < ClientAPI . ClientResponse < Response > >
134135) {
135136 koaRouter [ method ] ( route , async ( ctx , next ) => {
137+ let responseAdditionalInfo : Record < string , unknown > | undefined
136138 try {
137139 const context = new APIContext ( )
138140 const serverAPI = serverAPIFactory . createServerAPI ( context )
@@ -144,6 +146,7 @@ function sofieAPIRequest<API, Params, Body, Response>(
144146 ctx . request . body as unknown as Body
145147 )
146148 if ( ClientAPI . isClientResponseError ( response ) ) {
149+ responseAdditionalInfo = response . additionalInfo
147150 throw UserError . fromSerialized ( response . error )
148151 }
149152 ctx . body = JSON . stringify ( { status : response . success , result : response . result } )
@@ -176,7 +179,8 @@ function sofieAPIRequest<API, Params, Body, Response>(
176179 ctx . type = 'application/json'
177180 const bodyObj : APIRequestError = { status : errCode , message : errMsg }
178181 const details = extractErrorDetails ( e )
179- if ( details ) bodyObj [ 'details' ] = details
182+ if ( details ) bodyObj . details = details
183+ if ( responseAdditionalInfo ) bodyObj . additionalInfo = responseAdditionalInfo
180184 ctx . body = JSON . stringify ( bodyObj )
181185 ctx . status = errCode
182186 }
0 commit comments