Skip to content

Instantly share code, notes, and snippets.

@nalply
Created October 6, 2016 11:13
Show Gist options
  • Save nalply/a420a73d83c82e2c9cd50b14e7b57a8e to your computer and use it in GitHub Desktop.
Save nalply/a420a73d83c82e2c9cd50b14e7b57a8e to your computer and use it in GitHub Desktop.
makeErrorByStatus = function(statusCode, content) {
let message = `failed [${statusCode}]`;
if (content) {
const stringContent = typeof content == "string" ?
content : content.toString();
message += ' ' + truncate(stringContent.replace(/\n/g, ' '), MAX_LENGTH);
}
return new Error(message);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment