This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree 1 file changed +21
-1
lines changed 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,8 @@ func (c *Call) Do(f interface{}) *Call {
162
162
if ! ok {
163
163
panic (r )
164
164
}
165
- if ! strings .Contains (errMsg , "reflect: Call using" ) {
165
+ if ! strings .Contains (errMsg , "reflect: Call using" ) &&
166
+ ! strings .Contains (errMsg , "reflect.Set: value of" ) {
166
167
panic (r )
167
168
}
168
169
skipFrames := 8
@@ -277,6 +278,25 @@ func (c *Call) SetArg(n int, value interface{}) *Call {
277
278
case reflect .Slice :
278
279
setSlice (args [n ], v )
279
280
default :
281
+ defer func () {
282
+ if r := recover (); r != nil {
283
+ errMsg , ok := r .(string )
284
+
285
+ // We only handle a very specific panic
286
+ // If it's not that one, then we "rethrow" the panic
287
+ // This allows users to use functions that panic in their tests
288
+ if ! ok {
289
+ panic (r )
290
+ }
291
+ if ! strings .Contains (errMsg , "reflect: Call using" ) &&
292
+ ! strings .Contains (errMsg , "reflect.Set: value of" ) {
293
+ panic (r )
294
+ }
295
+ skipFrames := 8
296
+ stackTraceStr := "\n \n " + currentStackTrace (skipFrames )
297
+ c .t .Fatalf ("%s%+v" , errMsg , stackTraceStr )
298
+ }
299
+ }()
280
300
reflect .ValueOf (args [n ]).Elem ().Set (v )
281
301
}
282
302
return nil
You can’t perform that action at this time.
0 commit comments