File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,13 @@ describe("koa middlewares", () => {
74
74
75
75
}
76
76
77
+ class TestCustomAsyncMiddlewareWhichThrows implements KoaMiddlewareInterface {
78
+
79
+ async use ( context : any , next ?: Function ) : Promise < any > {
80
+ throw new NotAcceptableError ( "TestCustomAsyncMiddlewareWhichThrows" ) ;
81
+ }
82
+
83
+ }
77
84
@Controller ( )
78
85
class KoaMiddlewareController {
79
86
@@ -133,6 +140,12 @@ describe("koa middlewares", () => {
133
140
return "1234" ;
134
141
}
135
142
143
+ @Get ( "/customAsyncMiddlewareWhichThrows" )
144
+ @UseBefore ( TestCustomAsyncMiddlewareWhichThrows )
145
+ TestCustomAsyncMiddlewareWhichThrows ( ) {
146
+ return "1234" ;
147
+ }
148
+
136
149
}
137
150
} ) ;
138
151
@@ -199,4 +212,11 @@ describe("koa middlewares", () => {
199
212
} ) ;
200
213
} ) ;
201
214
202
- } ) ;
215
+ it ( "should handle errors in custom async middlewares" , ( ) => {
216
+ return chakram
217
+ . get ( "http://127.0.0.1:3001/customAsyncMiddlewareWhichThrows" )
218
+ . then ( ( response : any ) => {
219
+ expect ( response ) . to . have . status ( 406 ) ;
220
+ } ) ;
221
+ } ) ;
222
+ } ) ;
You can’t perform that action at this time.
0 commit comments