Skip to content

Commit cd09031

Browse files
committed
Instead of trimming stack traces to last frame of current project, include any other projects in src/ except for Revel
1 parent 8d01a05 commit cd09031

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

errors.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,25 @@ func (e *Error) SetLink(errorLink string) {
118118
// Return the character index of the first relevant stack frame, or -1 if none were found.
119119
// Additionally it returns the base path of the tree in which the identified code resides.
120120
func findRelevantStackFrame(stack string) (int, string) {
121-
if frame := strings.Index(stack, filepath.ToSlash(BasePath)); frame != -1 {
122-
return frame, BasePath
121+
// Find first item in SourcePath that isn't in RevelPath.
122+
// If first item is in RevelPath, keep track of position, trim and check again.
123+
partialStack := stack
124+
sourcePath := filepath.ToSlash(SourcePath)
125+
revelPath := filepath.ToSlash(RevelPath)
126+
sumFrame := 0
127+
for {
128+
frame := strings.Index(partialStack, sourcePath)
129+
revelFrame := strings.Index(partialStack, revelPath)
130+
131+
if frame == -1 {
132+
break
133+
} else if frame != revelFrame {
134+
return sumFrame + frame, SourcePath
135+
} else {
136+
// Need to at least trim off the first character so this frame isn't caught again.
137+
partialStack = partialStack[frame + 1:]
138+
sumFrame += frame + 1
139+
}
123140
}
124141
for _, module := range Modules {
125142
if frame := strings.Index(stack, filepath.ToSlash(module.Path)); frame != -1 {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy