diff --git a/packages/core/src/index.js b/packages/core/src/index.js index 78eeccf9..60d0d1b5 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -127,7 +127,8 @@ ezs.createPipeline = (input, commands, trap) => { trap.write({ type: 'Fatal run-time error', scope: 'statements', - message: e.message, + message: e.message.split('\n').shift(), + messageFull: e.message, sourceError: e.sourceError, sourceChunk: e.sourceChunk, }); diff --git a/packages/core/src/server/index.js b/packages/core/src/server/index.js index d8578dda..ea66e763 100644 --- a/packages/core/src/server/index.js +++ b/packages/core/src/server/index.js @@ -56,7 +56,7 @@ function createServer(ezs, serverPort, serverPath, workerId) { next(); }); app.use((error, request, response, next) => { - errorHandler(request, response)(error, 500); + errorHandler(request, response)(error, 400); next(); }); const server = controlServer(http.createServer(app)); diff --git a/packages/core/src/server/knownPipeline.js b/packages/core/src/server/knownPipeline.js index 2b5374b0..da880795 100644 --- a/packages/core/src/server/knownPipeline.js +++ b/packages/core/src/server/knownPipeline.js @@ -23,8 +23,11 @@ const typeFrom = ({ mimeType }) => (mimeType || 'application/json'); const onlyOne = (item) => (Array.isArray(item) ? item.shift() : item); const knownPipeline = (ezs) => (request, response, next) => { - - if (request.catched || !request.methodMatch(['POST', 'OPTIONS', 'HEAD']) || request.serverPath === false || !request.isPipeline()) { + if (request.catched + || !request.methodMatch(['POST', 'OPTIONS', 'HEAD']) + || request.serverPath === false + || !request.isPipeline() + ) { return next(); } request.catched = true; @@ -120,7 +123,7 @@ const knownPipeline = (ezs) => (request, response, next) => { decodedStream.destroy(); transformedStream.destroy(); responseStarted(); - next(e); + triggerError(e, 400); }); pipeline( @@ -130,7 +133,7 @@ const knownPipeline = (ezs) => (request, response, next) => { response, (e) => { responseStarted(); - next(e); + triggerError(e, 500); } ); @@ -142,7 +145,7 @@ const knownPipeline = (ezs) => (request, response, next) => { }) .on('error', (e) => { request.unpipe(rawStream); - triggerError(e); + triggerError(e, 500); }) .once('close', () => { if (emptyStream) {