github.com/blend/go-sdk@v1.20240719.1/ex/err_message.go (about) 1 /* 2 3 Copyright (c) 2024 - 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 // ErrMessage returns the exception message. 11 // This depends on if the err is itself an exception or not. 12 // If it is not an exception, this will return empty string. 13 func ErrMessage(err interface{}) string { 14 if err == nil { 15 return "" 16 } 17 if ex := As(err); ex != nil && ex.Class != nil { 18 return ex.Message 19 } 20 if typed, ok := err.(MessageProvider); ok && typed != nil { 21 return typed.Message() 22 } 23 return "" 24 }