Created
December 5, 2018 06:53
-
-
Save jrsinclair/27a3a8785131932d3f3a81fa554d4eff to your computer and use it in GitHub Desktop.
Elegant Error Handling Code Samples
This file contains 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
function splitCSVToRows(csvData) { | |
// There should always be a header row... so if there's no | |
// newline character, something is wrong. | |
return (csvData.indexOf('\n') < 0) | |
? left('No header row found in CSV data') | |
: right(csvData.split('\n')); | |
} | |
function processRows(headerFields, dataRows) { | |
// Note this is Array map, not Either map. | |
return dataRows.map(row => processRow(headerFields, row)); | |
} | |
function showMessages(messages) { | |
return `<ul class="Messages">${messages.join('\n')}</ul>`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment