Skip to content

Commit 9e2b004

Browse files
committed
start normalizing errors
1 parent 9cc8c55 commit 9e2b004

6 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/gateway.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as os from "os";
22
import * as _ from "lodash";
3-
import { FatalError } from "tslint/lib/error";
43
import { ServiceBroker, ServiceBrokerOptions } from "./broker";
5-
import { RecursivePartial } from "./interface";
4+
import { FatalError, RecursivePartial } from "./interface";
65
import { SchemaRegistry, SchemaRegistryOptions } from "./schema";
76
import { APIServer, APIServerOptions } from "./server";
87
import { Logger, LoggerConstructors, LoggerConstructorOptions } from "./logger";

src/interface/error.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// TODO: gather and normalize all the errors here
2+
3+
export class FatalError extends Error {
4+
}

src/interface/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from "./validation";
66
export * from "./keyed";
77
export * from "./pluggable";
88
export * from "./iterable";
9+
export * from "./error";

src/schema/branch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import AsyncLock from "async-lock";
22
import { EventEmitter } from "events";
33
import * as kleur from "kleur";
44
import * as _ from "lodash";
5-
import { FatalError } from "tslint/lib/error";
65
import { Reporter, Service } from "../broker";
7-
import { RecursivePartial, ValidationError } from "../interface";
6+
import { FatalError, RecursivePartial, ValidationError } from "../interface";
87
import { Logger } from "../logger";
98
import { ServiceCatalog } from "./catalog";
109
import { ProtocolPlugin } from "./plugin";
@@ -338,7 +337,9 @@ export class Branch {
338337
}
339338

340339
if (initialCompile) { // throw errors when failed in initial compile
341-
throw new FatalError("failed to compile empty schemata initially", errors as any); // TODO: normalize error
340+
const err: any = new FatalError("failed to compile empty schemata initially"); // TODO: normalize error
341+
err.detail = errors as any;
342+
throw err;
342343
} else {
343344
const at = new Date();
344345
const errorsTable = Reporter.getTable(errors.map(message => ({type: "error", message, at})));

src/schema/registry.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { EventEmitter } from "events";
22
import AsyncLock from "async-lock";
33
import * as kleur from "kleur";
44
import _ from "lodash";
5-
import { FatalError } from "tslint/lib/error";
6-
import { RecursivePartial, hashObject, validateObject, ValidationSchema, ValidationError, validateInlineFunction } from "../interface";
5+
import { FatalError, RecursivePartial, hashObject, validateObject, ValidationSchema, ValidationError, validateInlineFunction } from "../interface";
76
import { Reporter, Service, ServiceBroker } from "../broker";
87
import { Logger } from "../logger";
98
import { ServiceAPIIntegrationSource } from "./integration";

src/server/application/application.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import AsyncLock from "async-lock";
2-
import { FatalError } from "tslint/lib/error";
3-
import { RecursivePartial } from "../../interface";
2+
import { FatalError, RecursivePartial } from "../../interface";
43
import { Logger } from "../../logger";
54
import { Branch, Version } from "../../schema";
65
import {

0 commit comments

Comments
 (0)