{"action":"created","issue":{"url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/25","repository_url":"https://api.github.com/repos/numo-labs/aws-lambda-helper","labels_url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/25/comments","events_url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/25/events","html_url":"https://github.com/numo-labs/aws-lambda-helper/issues/25","id":146575958,"number":25,"title":"Can we add a method to helper to simplify error handling in our lambdas?","user":{"login":"nelsonic","id":194400,"avatar_url":"https://avatars.githubusercontent.com/u/194400?v=3","gravatar_id":"","url":"https://api.github.com/users/nelsonic","html_url":"https://github.com/nelsonic","followers_url":"https://api.github.com/users/nelsonic/followers","following_url":"https://api.github.com/users/nelsonic/following{/other_user}","gists_url":"https://api.github.com/users/nelsonic/gists{/gist_id}","starred_url":"https://api.github.com/users/nelsonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nelsonic/subscriptions","organizations_url":"https://api.github.com/users/nelsonic/orgs","repos_url":"https://api.github.com/users/nelsonic/repos","events_url":"https://api.github.com/users/nelsonic/events{/privacy}","received_events_url":"https://api.github.com/users/nelsonic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-07T10:36:18Z","updated_at":"2016-04-07T14:32:58Z","closed_at":null,"body":"Can be as simple as: (*though we can always add more if we need formatting for Kibana*)\r\n```js\r\nhelper.error = function (err, event, context) {\r\n  if (err) {\r\n    context.fail(err); // halt processing ?\r\n  } else {\r\n    return; // no error so continue processing;\r\n  }\r\n}\r\n```\r\nthis would allow use to 1-line error handling in our lambda. e.g:\r\n```js\r\nexports.handler = function (event, context) {\r\n  api_request(params, function (err, data) {\r\n    helper.error(err, event, context); // error handled or continue. no if/else in the body of lambda.\r\n    // continue processing data\r\n  });\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/comments/206933259","html_url":"https://github.com/numo-labs/aws-lambda-helper/issues/25#issuecomment-206933259","issue_url":"https://api.github.com/repos/numo-labs/aws-lambda-helper/issues/25","id":206933259,"user":{"login":"nelsonic","id":194400,"avatar_url":"https://avatars.githubusercontent.com/u/194400?v=3","gravatar_id":"","url":"https://api.github.com/users/nelsonic","html_url":"https://github.com/nelsonic","followers_url":"https://api.github.com/users/nelsonic/followers","following_url":"https://api.github.com/users/nelsonic/following{/other_user}","gists_url":"https://api.github.com/users/nelsonic/gists{/gist_id}","starred_url":"https://api.github.com/users/nelsonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nelsonic/subscriptions","organizations_url":"https://api.github.com/users/nelsonic/orgs","repos_url":"https://api.github.com/users/nelsonic/repos","events_url":"https://api.github.com/users/nelsonic/events{/privacy}","received_events_url":"https://api.github.com/users/nelsonic/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T14:32:58Z","updated_at":"2016-04-07T14:32:58Z","body":"@Kumjami, yes, I agree that we need an *intuitive* name for the method.\r\n\r\nThe error handler does not need to be *private* NPM project, \r\n[`aws-lambda-helper`](https://www.npmjs.com/package/aws-lambda-helper) is *public* because it contains no \"*sensative*\" or \"*proprietary*\" information. (*we try to make as much as possible public...*)\r\n\r\nWe are trying to avoid conditional execution (\"branching\") in our Lambdas so `case 1` in your example above would not improve the situation. \r\n\r\nWould you agree that `failOnError` describes the functionality more accurately?\r\n\r\nAlso, can you clarify what the *advantage* of a \"*factory*\" in this situation?"}}