Detalhes do pacote

error-stack2

bluelovers2.5kMIT2.0.7

Parse and manipulate error.stack

error-stack, error-stack-parser, formatter, trace

readme (leia-me)

Build Status Coverage

error-stack

Parse and manipulate error.stack

Install

$ npm i error-stack

Usage

const parse = require('error-stack')
const {stack} = new Error('foo')

console.log(stack)
// Error: foo
//     at repl:1:11
//     at Script.runInThisContext (vm.js:123:20)

const parsed = parse(stack)

parsed.type // Error

parsed.message  // foo

parsed.traces
// [
//   {
//     callee: undefined,
//     source: 'repl',
//     line: 1,
//     col: 11
//   },
//   {
//     callee: 'Script.runInThisContext',
//     source: 'vm.js',
//     line: 123,
//     col: 20
//   }
// ]

parsed
.filter(({callee}) => !!callee)
.format()
// Error: foo
//     at Script.runInThisContext (vm.js:123:20)

parsed.type string

Error type

parsed.message string

The message used by Error constructor

parsed.traces Array<Trace>

interface Source {
  // The source of the the callee
  source: string
  line?: number
  col?: number
}

interface Trace extends Source{
  callee: string
  // Whether the callee is 'eval'
  eval?: boolean
  // The source location inside eval content
  evalTrace: Source
}

parsed.filter(filterFunction): this

  • filterFunction Function the same as the callback function of Array.prototype.filter(callback)

Filters the current traces

parsed.format(): string

Format object parsed

License

MIT

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.0.5 (2023-10-19)

BREAKING CHANGES

  • update build

🛠 Build System

2.0.4 (2022-09-26)

🛠 Build System

📌 Dependencies

2.0.3 (2022-08-30)

🛠 Build System

2.0.2 (2022-02-02)

🐛 Bug Fixes

2.0.1 (2022-02-02)

🐛 Bug Fixes

BREAKING CHANGE

  • if message is undefined will return without :

1.0.18 (2022-02-01)

📦 Code Refactoring

1.0.17 (2021-12-06)

♻️ Chores

  • update package.json exports (2466df4)

🔖 Miscellaneous

1.0.15 (2021-12-06)

🔖 Miscellaneous

1.0.14 (2021-12-06)

🐛 Bug Fixes

1.0.13 (2021-12-06)

🛠 Build System

1.0.12 (2021-08-22)

Note: Version bump only for package error-stack2

1.0.11 (2021-08-22)

✨ Features

  • 支援 AssertionError [ERR_ASSERTION]: xxx (1e78530)
  • parseMessage 支援 AssertionError [ERR_ASSERTION]: xxx (36f9686)

1.0.10 (2021-08-22)

✨ Features

1.0.9 (2021-08-22)

Note: Version bump only for package error-stack2

1.0.8 (2021-08-22)

✨ Features

  • allow unsupported lines in traces (50deae0)

1.0.7 (2021-08-22)

🐛 Bug Fixes

✨ Features

  • support give message when parse (a2185c0)
  • support detect indent (a684d83)

📦 Code Refactoring

1.0.6 (2021-08-19)

🐛 Bug Fixes

  • support empty message (0ebfccb)
  • support eval at <anonymous> (:1:1) (1bd29d3)

⚙️ Continuous Integration

🔖 Miscellaneous

1.0.5 (2021-08-18)

✨ Features

1.0.4 (2021-08-18)

🐛 Bug Fixes

  • 修正 eval 與 at new Promise (<anonymous>) (6b61b32)
  • parseSource with C:\\xxx (5c99d89)

📦 Code Refactoring

🛠 Build System

🔖 Miscellaneous

1.0.3 "🔖 Miscellaneous" (2020-03-26)

🔖 Miscellaneous

  • bump version 1.0.3 (81490f9)
  • Merge pull request #1 from vivaxy/patch-1 (e474458), closes #1

1.0.2 "🔖 Miscellaneous" (2019-08-16)

🔖 Miscellaneous

  • 1.0.2: fixes error stack with multiple lines (dc10da0)
  • removes stale comments (1bcc1e4)
  • Fix demo in usage (23f750d)

1.0.1 "🔖 Miscellaneous" (2019-06-12)

🔖 Miscellaneous

  • 1.0.1: fixes brackets balancing (ae6f3bd)

1.0.0 "🔖 Miscellaneous" (2019-06-12)

🔖 Miscellaneous