Skip to content

Commit 9329516

Browse files
committed
better test for errors before yield
1 parent 36dd638 commit 9329516

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/response/stream.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,15 @@ describe('Stream', () => {
7171
'event: message\ndata: "a"\n\nevent: error\ndata: "an error"\n\n'
7272
)
7373
})
74-
74+
7575
it('handle errors before yield', async () => {
76-
const app = new Elysia().get('/', async function* () {
77-
throw new Error('an error')
78-
})
76+
const app = new Elysia()
77+
.onError(({ error }) => {
78+
return new Response(error.message)
79+
})
80+
.get('/', async function* () {
81+
throw new Error('an error')
82+
})
7983

8084
const response = await app.handle(req('/')).then((x) => x.text())
8185

0 commit comments

Comments
 (0)