Files
fluence-js/src/internal/defaultMiddlewares.ts
Pavel 6436cd5684 Update JS SDK API to the new version (#61)
* FluenceClient renamed to FluencePeer.
* Using Aqua compiler is now the recommended way for all interaction with the network, including services registration and sending requests
* Old API (sendParticle etc) has been removed
* Opaque seed format replaced with 32 byte ed25519 private key. KeyPair introduced
* Documentation update
2021-09-08 12:42:30 +03:00

15 lines
496 B
TypeScript

import { CallServiceArg, CallServiceData, CallServiceResult, Middleware, ResultCodes } from './CallServiceHandler';
/**
* Error catching middleware
*/
export const errorHandler: Middleware = (req: CallServiceData, resp: CallServiceResult, next: Function): void => {
try {
next();
} catch (e) {
resp.retCode = ResultCodes.exceptionInHandler;
resp.result = `Handler failed. fnName="${req.fnName}" serviceId="${req.serviceId}" error: ${e.toString()}`;
}
};
1;