Skip to content

Instantly share code, notes, and snippets.

@jrsinclair
Created December 5, 2018 06:51
Show Gist options
  • Save jrsinclair/7560421adaebb5d0b517c9963f482fa4 to your computer and use it in GitHub Desktop.
Save jrsinclair/7560421adaebb5d0b517c9963f482fa4 to your computer and use it in GitHub Desktop.
Elegant Error Handling Code Samples
function processRow(headerFields, row) {
const fieldsEither = right(row).map(splitFields);
const rowObj = fieldsEither.chain(zipRow(headerFields));
const rowObjWithDate = rowObj.chain(addDateStr);
return either(showError, rowToMessage, rowObjWithDate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment