Setup eslint and enforce rules
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-06-02 22:36:25 -05:00
parent 82e7a1f299
commit 1d5056b753
149 changed files with 6104 additions and 3114 deletions

View File

@@ -1,7 +1,7 @@
import * as color from 'colors/safe'
import {Logging} from "../service/Logging";
import {Inject} from "../di";
import {ErrorWithContext} from "../util";
import {Logging} from '../service/Logging'
import {Inject} from '../di'
import {ErrorWithContext} from '../util'
/**
* Class with logic for handling errors that are thrown at the run-level of the application.
@@ -30,7 +30,8 @@ export class RunLevelErrorHandler {
*/
wrapContext(e: Error, context: {[key: string]: any}): ErrorWithContext {
if ( e instanceof ErrorWithContext ) {
e.context = {...e.context, ...context}
e.context = {...e.context,
...context}
return e
}
@@ -45,15 +46,18 @@ export class RunLevelErrorHandler {
* Log the error to the logger.
* @param {Error} e
*/
display(e: Error) {
display(e: Error): void {
let operativeError = e
let context: {[key: string]: string} = {}
if ( e instanceof ErrorWithContext ) {
if ( e.originalError ) operativeError = e.originalError
if ( e.originalError ) {
operativeError = e.originalError
}
context = e.context
}
const contextDisplay = Object.keys(context).map(key => ` - ${key}: ${context[key]}`).join('\n')
const contextDisplay = Object.keys(context).map(key => ` - ${key}: ${context[key]}`)
.join('\n')
try {
let errorString = `RunLevelErrorHandler invoked:
@@ -73,12 +77,12 @@ With the following context:
${contextDisplay}
`
}
this.logging.error(errorString, true)
} catch (display_e) {
} catch (displayError) {
// The error display encountered an error...
// just throw the original so it makes it out
console.error('RunLevelErrorHandler encountered an error:', display_e.message)
console.error('RunLevelErrorHandler encountered an error:', displayError.message) // eslint-disable-line no-console
throw operativeError
}
}