I have to checkpoint this because I'm trying to get a very complicated multi-layered SQL query for inserting version history into the database and I need to improve it iteratively I've got a new binary that I can use to directly test complex stored procedures. This is to shorted my testing loop.
26 lines
514 B
Go
26 lines
514 B
Go
package db
|
|
|
|
import (
|
|
"errors"
|
|
"reflect"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func LogErrorTypeInfo(err error) {
|
|
if err == nil {
|
|
log.Error().Msg("Error is nil")
|
|
return
|
|
}
|
|
|
|
// Log current error type
|
|
errType := reflect.TypeOf(err)
|
|
log.Warn().Err(err).Str("type", errType.String()).Str("pkgPath", errType.PkgPath()).Msg("Error type info")
|
|
|
|
// Recursively log wrapped errors
|
|
wrappedErr := errors.Unwrap(err)
|
|
if wrappedErr != nil {
|
|
log.Info().Msg("Contains wrapped error")
|
|
LogErrorTypeInfo(wrappedErr)
|
|
}
|
|
}
|