app.ts: Fix createApp to log all http server errors
cc @code-asher
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import * as http from "http"
|
||||
import { logger } from "@coder/logger"
|
||||
import { ensureAddress } from "../src/node/app"
|
||||
import * as nodeFetch from "node-fetch"
|
||||
import * as util from "../src/common/util"
|
||||
import { ensureAddress } from "../src/node/app"
|
||||
|
||||
export class HttpServer {
|
||||
private hs = http.createServer()
|
||||
@ -25,7 +25,7 @@ export class HttpServer {
|
||||
rej(err)
|
||||
} else {
|
||||
// Promise resolved earlier so this is some other error.
|
||||
logError("server error", err)
|
||||
util.logError("http server error", err)
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -54,12 +54,3 @@ export class HttpServer {
|
||||
return nodeFetch.default(`${ensureAddress(this.hs)}${requestPath}`, opts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function logError(prefix: string, err: any): void {
|
||||
if (err instanceof Error) {
|
||||
logger.error(`${prefix}: ${err.message} ${err.stack}`)
|
||||
} else {
|
||||
logger.error(`${prefix}: ${err}`)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user