Skip to content

Commit

Permalink
fix(lambda): additional error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wyvern8 committed Jun 29, 2018
1 parent e9da3d8 commit c4f0084
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/KmsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class KmsUtils {
return this.store[encrypted];
} else {
this.logger.info(`returning newly decrypted value`);
return await this.decrypt(encrypted);
return await this.decrypt(encrypted).catch(e => {
console.error(`failed to decrypt ${encrypted}. error: ${JSON.stringify(e)}`);
});
}
}
setDecrypted(encrypted, decrypted) {
Expand Down
10 changes: 5 additions & 5 deletions src/serverless/gtmGithubHook/gtmGithubHook.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict';

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});

console.log('cold start');
require('source-map-support').install();
let rp = require('request-promise-native');
Expand All @@ -10,11 +15,6 @@ let githubUtils = require('../gtmGithubUtils.js');

import KmsUtils from './../../KmsUtils';

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});

async function listener(event, context, callback) {
console.log(
`hook call from ${event.requestContext.identity.sourceIp} forwarded for ${event.headers['X-Forwarded-For']}`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict';

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});

console.log('cold start');
const AWS = require('aws-sdk');
const HTTPS = require('https');
Expand Down
2 changes: 1 addition & 1 deletion src/serverless/gtmGithubUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ async function handleEventTaskResult(message, done) {
let updaterFunction = githubUpdaters[status.eventData.ghEventType];

if (updaterFunction) {
return updaterFunction(status, done);
return await updaterFunction(status, done);
} else {
console.error(`gitub updates for event type '${status.eventData.ghEventType}' are not supported yet.`);
done();
Expand Down

0 comments on commit c4f0084

Please sign in to comment.