This commit is contained in:
parent
8d1dcc87fb
commit
9ee4c42e43
@ -169,8 +169,11 @@ export abstract class Directive extends AppClass {
|
|||||||
const optionValues = this.parseOptions(options, argv)
|
const optionValues = this.parseOptions(options, argv)
|
||||||
this.setOptionValues(optionValues)
|
this.setOptionValues(optionValues)
|
||||||
await this.handle(argv)
|
await this.handle(argv)
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
this.nativeOutput(e.message)
|
if ( e instanceof Error ) {
|
||||||
|
this.nativeOutput(e.message)
|
||||||
|
}
|
||||||
|
|
||||||
if ( e instanceof OptionValidationError ) {
|
if ( e instanceof OptionValidationError ) {
|
||||||
// expecting, value, requirements
|
// expecting, value, requirements
|
||||||
if ( e.context.expecting ) {
|
if ( e.context.expecting ) {
|
||||||
@ -187,6 +190,7 @@ export abstract class Directive extends AppClass {
|
|||||||
this.nativeOutput(` - ${e.context.value}`)
|
this.nativeOutput(` - ${e.context.value}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nativeOutput('\nUse --help for more info.')
|
this.nativeOutput('\nUse --help for more info.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,12 @@ export class Application extends Container {
|
|||||||
try {
|
try {
|
||||||
await this.up()
|
await this.up()
|
||||||
await this.down()
|
await this.down()
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
this.errorHandler(e)
|
if ( e instanceof Error ) {
|
||||||
|
this.errorHandler(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,9 +310,14 @@ export class Application extends Container {
|
|||||||
await unit.up()
|
await unit.up()
|
||||||
unit.status = UnitStatus.Started
|
unit.status = UnitStatus.Started
|
||||||
logging.info(`Started ${unit.constructor.name}.`)
|
logging.info(`Started ${unit.constructor.name}.`)
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
unit.status = UnitStatus.Error
|
unit.status = UnitStatus.Error
|
||||||
throw this.errorWrapContext(e, {unitName: unit.constructor.name})
|
|
||||||
|
if ( e instanceof Error ) {
|
||||||
|
throw this.errorWrapContext(e, {unitName: unit.constructor.name})
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +336,12 @@ export class Application extends Container {
|
|||||||
logging.info(`Stopped ${unit.constructor.name}.`)
|
logging.info(`Stopped ${unit.constructor.name}.`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
unit.status = UnitStatus.Error
|
unit.status = UnitStatus.Error
|
||||||
throw this.errorWrapContext(e, {unitName: unit.constructor.name})
|
|
||||||
|
if ( e instanceof Error ) {
|
||||||
|
throw this.errorWrapContext(e, {unitName: unit.constructor.name})
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,13 @@ ${contextDisplay}
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logging.error(errorString, true)
|
this.logging.error(errorString, true)
|
||||||
} catch (displayError) {
|
} catch (displayError: unknown) {
|
||||||
// The error display encountered an error...
|
if ( displayError instanceof Error ) {
|
||||||
// just throw the original so it makes it out
|
// The error display encountered an error...
|
||||||
console.error('RunLevelErrorHandler encountered an error:', displayError.message) // eslint-disable-line no-console
|
// just throw the original so it makes it out
|
||||||
|
console.error('RunLevelErrorHandler encountered an error:', displayError.message) // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
|
||||||
throw operativeError
|
throw operativeError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,12 @@ export class PostgresConnection extends Connection {
|
|||||||
rowCount: result.rowCount,
|
rowCount: result.rowCount,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw this.app().errorWrapContext(e, {
|
if ( e instanceof Error ) {
|
||||||
query,
|
throw this.app().errorWrapContext(e, {
|
||||||
connection: this.name,
|
query,
|
||||||
})
|
connection: this.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Inject, Singleton} from '../di'
|
import {Inject, Singleton} from '../di'
|
||||||
import {HTTPStatus, withTimeout} from '../util'
|
import {ErrorWithContext, HTTPStatus, withTimeout} from '../util'
|
||||||
import {Unit} from '../lifecycle/Unit'
|
import {Unit} from '../lifecycle/Unit'
|
||||||
import {createServer, IncomingMessage, RequestListener, Server, ServerResponse} from 'http'
|
import {createServer, IncomingMessage, RequestListener, Server, ServerResponse} from 'http'
|
||||||
import {Logging} from './Logging'
|
import {Logging} from './Logging'
|
||||||
@ -114,7 +114,11 @@ export class HTTPServer extends Unit {
|
|||||||
try {
|
try {
|
||||||
await this.kernel.handle(extolloReq)
|
await this.kernel.handle(extolloReq)
|
||||||
} catch (e) {
|
} 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()
|
await extolloReq.response.send()
|
||||||
|
@ -137,7 +137,7 @@ export class BehaviorSubject<T> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ( e instanceof UnsubscribeError ) {
|
if ( e instanceof UnsubscribeError ) {
|
||||||
this.subscribers = this.subscribers.filter(x => x !== subscriber)
|
this.subscribers = this.subscribers.filter(x => x !== subscriber)
|
||||||
} else if (subscriber.error) {
|
} else if (subscriber.error && e instanceof Error) {
|
||||||
await subscriber.error(e)
|
await subscriber.error(e)
|
||||||
} else {
|
} else {
|
||||||
throw e
|
throw e
|
||||||
@ -181,7 +181,7 @@ export class BehaviorSubject<T> {
|
|||||||
try {
|
try {
|
||||||
await subscriber.complete(finalValue)
|
await subscriber.complete(finalValue)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ( subscriber.error ) {
|
if ( subscriber.error && e instanceof Error ) {
|
||||||
await subscriber.error(e)
|
await subscriber.error(e)
|
||||||
} else {
|
} else {
|
||||||
throw e
|
throw e
|
||||||
|
@ -92,7 +92,7 @@ export class LocalFilesystem extends Filesystem {
|
|||||||
isFile: stat.isFile(),
|
isFile: stat.isFile(),
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ( e?.code === 'ENOENT' ) {
|
if ( (e as any)?.code === 'ENOENT' ) {
|
||||||
return {
|
return {
|
||||||
path: new UniversalPath(args.storePath, this),
|
path: new UniversalPath(args.storePath, this),
|
||||||
exists: false,
|
exists: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user