1.0.4 • Published 5 years ago

better-error-objects v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Better Error Objects

Better Error Objects is a NodeJS library used to turn the stack of an Error into Objects.

Installation

Use the package manager npm to install Better Error Objects.

npm install --save better-error-objects

Usage

const BEO = require('better-error-objects');

let error = BEO.objectify(new Error()); //Returns the Error Object with the stack as objects as well.

Structure of the Error Object:

{  
   "name":"string",
   "message":"string",
   "stack":[  
      {  
         "function":"string",
         "trace":{  
            "path":"string",
            "file":{  
               "name":"string",
               "line":"number",
               "position":"number"
            }
         }
      },
      {  
         "function":"string",
         "trace":{  
            "path":"string",
            "file":{  
               "name":"string",
               "line":"number",
               "position":"number"
            }
         }
      }
   ]
}

Example

const BEO = require('better-error-objects');

let error = BEO.objectify(new Error());
console.log(JSON.stringify(error.stack[1]));  
//Returns:
{
  "function": "Module._compile",
  "trace": {
    "path": "internal/modules/cjs",
    "file": {
      "name": "loader.js",
      "line": 689,
      "position": 30
    }
  }
}

Contributing

While you are free to add or change the code as you wish, I do not see a reason why you'd want to contribute to this one-time package. But of course, if you wish to add to this project, feel free to do so.

License

ISC

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago