Created
March 17, 2017 18:56
-
-
Save wbprice/d3e62904301b5e49bd0f8e94e0e2205e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server.route({ | |
| method: 'POST', | |
| path: settings.errorRoute, | |
| handler: function handleRoute(request, reply) { | |
| // We're only interested in handling application/json payloads. | |
| if (request.mime !== 'application/json') { | |
| return reply(boom.unsupportedMediaType()); | |
| } | |
| return joi.validate(request && request.payload, internals.schema.payload, function(err) { | |
| if (err) { | |
| return reply(boom.badRequest(`${err.name}: {err.message}`)); | |
| } | |
| let uuid = uuidLookup.read(request); | |
| let sessionId = request.session && request.session.id; | |
| // Log all the reports | |
| request.payload.errorLogs.forEach(function(errorLog) { | |
| // If the UUID and Session ID are available, add them to the log. | |
| errorLog.uuid = uuid; | |
| errorLog.sessionId = sessionId; | |
| request.log('client error', jsesc(reduce(errorLog, function(memo, value, key) { | |
| memo += `${key}='${value}'; `; | |
| return memo; | |
| }, ''))); | |
| }); | |
| return reply(); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment