Skip to content

Instantly share code, notes, and snippets.

@LuckyArdhika
Created December 8, 2022 07:46
Show Gist options
  • Save LuckyArdhika/8f8f4600367e71d8e841d765d7d6628a to your computer and use it in GitHub Desktop.
Save LuckyArdhika/8f8f4600367e71d8e841d765d7d6628a to your computer and use it in GitHub Desktop.
NodeJS Error Logger with Details...
try {
// block code of try
console.log("[+] Return: ", result);
return result;
} catch (err) {
console.log({
type: "Error Logger",
data: {
Path: req.path,
Method: req.method,
ErrorStack: err,
ErrorMessage: err.message,
ErorStatus: err.status,
RequestBody: req.body || request.body || body
});
// return or other code block
} finaly {
// block code of finally
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment