Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 377377b

Browse files
committed
Manually replace file versions in stack trace wrapping
1 parent a633e3a commit 377377b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

types/errors/stacktrace.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,26 @@ func writeSimpleFrame(s io.Writer, f errors.Frame) {
7373
if len(chunks) == 2 {
7474
file = chunks[1]
7575
}
76+
// replace specific file versions in stack trace
77+
file = replaceWasmdVersionStr(file)
78+
file = replaceSeiCosmosVersionStr(file)
7679
fmt.Fprintf(s, " [%s:%d]", file, line)
7780
}
7881

82+
func replaceWasmdVersionStr(err string) string {
83+
return strings.Replace(err, "sei-wasmd@v0.3.11", "sei-wasmd@v0.3.10", 1)
84+
}
85+
86+
func replaceSeiCosmosVersionStr(err string) string {
87+
return strings.Replace(err, "sei-cosmos@v0.3.67", "sei-cosmos@v0.3.66", 1)
88+
}
89+
7990
// Format works like pkg/errors, with additions.
8091
// %s is just the error message
8192
// %+v is the full stack trace
8293
// %v appends a compressed [filename:line] where the error
83-
// was created
94+
//
95+
// was created
8496
//
8597
// Inspired by https://github.com/pkg/errors/blob/v0.8.1/errors.go#L162-L176
8698
func (e *wrappedError) Format(s fmt.State, verb rune) {

types/errors/stacktrace_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (s *errorsTestSuite) TestStackTrace() {
3939
const thisTestSrc = "types/errors/stacktrace_test.go"
4040

4141
for _, tc := range cases {
42-
s.Require().True(reflect.DeepEqual(tc.err.Error(), tc.wantError))
42+
s.Require().True(reflect.DeepEqual(tc.err.Error(), tc.wantError), tc.err.Error(), tc.wantError)
4343
s.Require().NotNil(stackTrace(tc.err))
4444
fullStack := fmt.Sprintf("%+v", tc.err)
4545
s.Require().True(strings.Contains(fullStack, thisTestSrc))
@@ -60,3 +60,17 @@ func (s *errorsTestSuite) TestStackTrace() {
6060
s.Require().True(strings.Contains(tinyStack, thisTestSrc))
6161
}
6262
}
63+
64+
func (s *errorsTestSuite) TestReplaceWasmdVersionStr() {
65+
input := "sei-wasmd@v0.3.11/some/path/file.go"
66+
expected := "sei-wasmd@v0.3.10/some/path/file.go"
67+
result := replaceWasmdVersionStr(input)
68+
s.Require().Equal(expected, result)
69+
}
70+
71+
func (s *errorsTestSuite) TestReplaceSeiCosmosVersionStr() {
72+
input := "sei-cosmos@v0.3.67/some/path/file.go"
73+
expected := "sei-cosmos@v0.3.66/some/path/file.go"
74+
result := replaceSeiCosmosVersionStr(input)
75+
s.Require().Equal(expected, result)
76+
}

0 commit comments

Comments
 (0)