Repository navigation
fix: slice off all leading lines of multiline error message in clean() - #78
Open
chiragbitoni wants to merge 1 commit into
Open
chiragbitoni wants to merge 1 commit into
chiragbitoni wants to merge 1 commit into
Conversation
Previously, clean() checked if line 0 was not an at line and line 1 was an at line, assuming error messages were always a single line. When an error message spanned multiple lines, none of the message lines were sliced off before the loop, causing the last message line to be retained as a leading header before the first frame. Use findIndex to locate the first at frame and slice off all preceding message lines. Fixes tapjs#53 Signed-off-by: Chirag Bitoni <chiragbitoni4994@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When cleaning a stack trace from an error with a multiline message (for example:
throw new TypeError(foo\nbar\nbaz)),clean()previously tested:Because
stack[1]is another line of the message rather than anatframe, no lines were sliced off before the loop, and the last line of the multiline message (baz) was retained aslastNonAtLineand output before the first frame.This PR uses
stack.findIndex(line => /^\s*at /.test(line))to locate the first frame index, slicing off all preceding lines belonging to the leading error message.Fixes #53
Checklist