rpcapi
Advanced tools
Comparing version 2.5.0 to 2.6.0
{ | ||
"name": "rpcapi", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Provides a struture for hosting RPC style APIs, supports both http and websocket access out of the box", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -94,2 +94,3 @@ "use strict"; | ||
}).catch(function (e) { | ||
_this.api.handleError(e); | ||
if (e instanceof errorTypes_1.AccessDeniedError) { | ||
@@ -100,2 +101,3 @@ debug("socket id: '" + socket.id + "', connecting to endpoint '" + endpointName + "' - failed, access denied"); | ||
} | ||
console.error(e); | ||
debug("socket id: '" + socket.id + "', connecting to endpoint '" + endpointName + "' - failed, %o", e); | ||
@@ -132,2 +134,3 @@ cb("Unable to create endpoint connection, '" + endpointName + "' threw an error while setting up", null); | ||
} | ||
_this.api.handleError(e); | ||
if (_this.outputActionErrors) { | ||
@@ -151,2 +154,3 @@ console.error(e); | ||
// we don't want to crash the program because of an error here, just log it | ||
_this.api.handleError(e); | ||
console.error(e); | ||
@@ -153,0 +157,0 @@ } |
@@ -12,6 +12,8 @@ /// <reference types="node" /> | ||
customCreateEndpointInstance: (epClass: any) => APIEndpoint; | ||
handleError: (error: Error) => void; | ||
private endpoints; | ||
registerEndpoint(endpointName: string, endpointClass: any): void; | ||
getEndpoint(endpointName: string): APIEndpoint; | ||
registerErrorHandler(errorHandler: (err: Error) => void): void; | ||
listen(port: number, options?: IAPIListenConfig): Promise<void>; | ||
} |
@@ -18,2 +18,5 @@ "use strict"; | ||
this.customCreateEndpointInstance = null; | ||
this.handleError = function (error) { | ||
console.error(error); | ||
}; | ||
this.endpoints = Object.create(null); | ||
@@ -40,2 +43,5 @@ } | ||
}; | ||
API.prototype.registerErrorHandler = function (errorHandler) { | ||
this.handleError = errorHandler; | ||
}; | ||
//Magic function to setup express and socket.io server | ||
@@ -57,2 +63,3 @@ //Convenient for any apps that have no need to manage express and socket.io themselves | ||
res.end('{"error":"Internal server error","result":null}'); | ||
_this.handleError(err); | ||
console.error(err); | ||
@@ -59,0 +66,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
336468
4740