Skip to content

Commit 6a67a9c

Browse files
committed
Fix typings in service.worker.runtime.http.middlewares.error
Only make operations with status codes if the error is an AxiosError
1 parent ed20d6d commit 6a67a9c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

  • src/service/worker/runtime/http/middlewares

src/service/worker/runtime/http/middlewares/error.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AxiosError } from 'axios'
12
import { IOClients } from '../../../../../clients/IOClients'
23
import { LINKED } from '../../../../../constants'
34
import {
@@ -102,12 +103,13 @@ export async function error (ctx: ServiceContext, next: () => Promise<void>) {
102103
const err = cleanError(e)
103104

104105
// Add response
105-
ctx.status = e && e.status >= 400 && e.status <= 599
106-
? e.status
107-
: ctx.status >= 500 && ctx.status <= 599
108-
? ctx.status
109-
: 500
110-
106+
if(e instanceof AxiosError){
107+
ctx.status = e?.status && e.status >= 400 && e.status <= 599
108+
? e.status
109+
: ctx.status >= 500 && ctx.status <= 599
110+
? ctx.status
111+
: 500
112+
}
111113
// Do not generate etag for errors
112114
ctx.remove(META_HEADER)
113115
ctx.remove(ETAG_HEADER)

0 commit comments

Comments
 (0)