github.com/blend/go-sdk@v1.20220411.3/ex/err_stack_trace.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package ex 9 10 // ErrStackTrace returns the exception stack trace. 11 // This depends on if the err is itself an exception or not. 12 func ErrStackTrace(err interface{}) StackTrace { 13 if err == nil { 14 return nil 15 } 16 if ex := As(err); ex != nil && ex.StackTrace != nil { 17 return ex.StackTrace 18 } 19 if typed, ok := err.(StackTraceProvider); ok && typed != nil { 20 return typed.StackTrace() 21 } 22 return nil 23 }