Created
December 8, 2022 07:46
-
-
Save LuckyArdhika/8f8f4600367e71d8e841d765d7d6628a to your computer and use it in GitHub Desktop.
NodeJS Error Logger with Details...
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
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