Error type fixes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-10-18 13:03:28 -05:00
parent 8d1dcc87fb
commit 9ee4c42e43
7 changed files with 47 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
import {Inject, Singleton} from '../di'
import {HTTPStatus, withTimeout} from '../util'
import {ErrorWithContext, HTTPStatus, withTimeout} from '../util'
import {Unit} from '../lifecycle/Unit'
import {createServer, IncomingMessage, RequestListener, Server, ServerResponse} from 'http'
import {Logging} from './Logging'
@@ -114,7 +114,11 @@ export class HTTPServer extends Unit {
try {
await this.kernel.handle(extolloReq)
} catch (e) {
await error(e).write(extolloReq)
if ( e instanceof Error ) {
await error(e).write(extolloReq)
}
await error(new ErrorWithContext('Unknown error occurred.', { e }))
}
await extolloReq.response.send()