Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
boywithkeyboard committed Aug 16, 2023
1 parent 0119919 commit 7924ee1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cheetah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OAuthStore } from './oauth/mod.ts'
import { OAuthSessionData } from './oauth/types.ts'
import { ResponseContext } from './response_context.ts'
import { Exception } from './context.ts'
import { Exception as OriginalException } from './exception.ts'

export type AppContext = {
env: Record<string, unknown> | undefined
Expand Down Expand Up @@ -381,7 +382,7 @@ export class cheetah extends base<cheetah>() {
} catch (err) {
let res: Response

if (err instanceof Exception) {
if (err instanceof Exception || err instanceof OriginalException) {
res = err.response(req)
} else {
if (this.#debug) {
Expand Down
5 changes: 4 additions & 1 deletion test/exception.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import cheetah, { Exception } from '../mod.ts'
import cheetah from '../mod.ts'
import { assertEquals } from './deps.ts'
import { Exception } from '../exception.ts'

// TODO write test suite for new c.exception() instead

Deno.test('Exception', async () => {
const app = new cheetah()
Expand Down
8 changes: 0 additions & 8 deletions test/preflight_mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,12 @@ Deno.test('preflight mode', async (t) => {
const res1 = await app.fetch(new Request('https://deno.com/foo'))

assertEquals(res1.body === null, false)
assertEquals(
res1.headers.get('content-length'),
'Something Went Wrong'.length.toString(),
)

const res2 = await app.fetch(
new Request('https://deno.com/foo', { method: 'HEAD' }),
)

assertEquals(res2.body === null, true)
assertEquals(
res2.headers.get('content-length'),
'Something Went Wrong'.length.toString(),
)
})

await t.step('error (custom)', async () => {
Expand Down

0 comments on commit 7924ee1

Please sign in to comment.