Skip to content

Instantly share code, notes, and snippets.

@LuckyArdhika
Created December 8, 2022 07:46
Show Gist options
  • Select an option

  • Save LuckyArdhika/8f8f4600367e71d8e841d765d7d6628a to your computer and use it in GitHub Desktop.

Select an option

Save LuckyArdhika/8f8f4600367e71d8e841d765d7d6628a to your computer and use it in GitHub Desktop.

Revisions

  1. LuckyArdhika created this gist Dec 8, 2022.
    22 changes: 22 additions & 0 deletions ErrorLogger.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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

    }