1 | import {injectable} from 'inversify';
|
2 | import {ForceError} from "../interfaces/force-error";
|
3 |
|
4 | @injectable()
|
5 | export class ForceErrorImpl implements ForceError {
|
6 | forceError: boolean = false;
|
7 |
|
8 |
|
9 | checkForceError(message: string, cb: (err: Error, anything: any, anything2?: any) => void = null): boolean {
|
10 | if (this.forceError && typeof cb === 'function') {
|
11 | cb(new Error(`force error: ${message}`), null);
|
12 | }
|
13 | return this.forceError;
|
14 | }
|
15 |
|
16 | checkCallback(cb: (err: Error, anything: any, anything2?: any) => void): (err: Error, anything: any, anything2?: any) => void {
|
17 | return (typeof cb === 'function')
|
18 | ? cb
|
19 | : () => {
|
20 | };
|
21 | }
|
22 | }
|