stacktracejs / error-stack-parser

Extract meaning from JS Errors
https://www.stacktracejs.com/#!/docs/error-stack-parser
MIT License
456 stars 52 forks source link

fix: fixed parsing for node #66

Closed Aleksey28 closed 2 years ago

Aleksey28 commented 3 years ago

Description

  1. added pre-replace unnecessary part of the line instead of slicing it after splitting
  2. fixed removing last round bracket during throwing out eval information
  3. removed regexp group ':(\d+):(\d+)' because we should get any location in brackets
  4. removed splitting 'sanitizedLine' and reorganized using 'sanitizedLine' and 'location'
  5. added a new option for node error test when the function name isn't there

Motivation and Context

I have a problem with the Node.js product. In some ways error looks like this:

Error
    at /var/app/scratch/my project/index.js:2:9
    at Object.<anonymous> (/var/app/scratch/my project/index.js:2:9)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11

First-line doesn't have a function name and round brackets and it loses full file name after splitting.

How Has This Been Tested?

Added new option for test 'should handle spaces in Node.js stacks'

Types of changes

Checklist:

niftylettuce commented 2 years ago

@Aleksey28 I wanted to follow up - I haven't had a chance to closely review this - but I would love to merge. Is this ready to go? I see you haven't checked off two checkboxes in the checklist above (docs and running that script without errors).

Aleksey28 commented 2 years ago

@niftylettuce Yes, it's ready to go. I haven't checked because they're unnecessary and they just were in the template of the PR. I think it outdated checkboxes

niftylettuce commented 2 years ago

Ping @eriwen for npm owner access so I can publish v2.0.7 via np

niftylettuce commented 2 years ago

v2.0.7 published, thanks again @eriwen 🙏 cc @Aleksey28

https://github.com/stacktracejs/error-stack-parser/releases/tag/v2.0.7