Skip to content

Commit 57885dc

Browse files
authored
Merge pull request revel#1082 from jchavannes/master
Less aggressive trimming of stack traces
2 parents fa0fa65 + cd09031 commit 57885dc

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
@@ -122,8 +122,25 @@ func (e *Error) SetLink(errorLink string) {
122122
// Return the character index of the first relevant stack frame, or -1 if none were found.
123123
// Additionally it returns the base path of the tree in which the identified code resides.
124124
func findRelevantStackFrame(stack string) (int, string) {
125-
if frame := strings.Index(stack, filepath.ToSlash(BasePath)); frame != -1 {
126-
return frame, BasePath
125+
// Find first item in SourcePath that isn't in RevelPath.
126+
// If first item is in RevelPath, keep track of position, trim and check again.
127+
partialStack := stack
128+
sourcePath := filepath.ToSlash(SourcePath)
129+
revelPath := filepath.ToSlash(RevelPath)
130+
sumFrame := 0
131+
for {
132+
frame := strings.Index(partialStack, sourcePath)
133+
revelFrame := strings.Index(partialStack, revelPath)
134+
135+
if frame == -1 {
136+
break
137+
} else if frame != revelFrame {
138+
return sumFrame + frame, SourcePath
139+
} else {
140+
// Need to at least trim off the first character so this frame isn't caught again.
141+
partialStack = partialStack[frame + 1:]
142+
sumFrame += frame + 1
143+
}
127144
}
128145
for _, module := range Modules {
129146
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