github.com/blend/go-sdk@v1.20220411.3/validate/error.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 validate 9 10 import ( 11 "fmt" 12 13 "github.com/blend/go-sdk/ex" 14 ) 15 16 // Error returns a new validation error. 17 // The root class of the error will be ErrValidation. 18 // The root stack will begin the frame above this call to error. 19 // The inner error will the cause of the validation vault. 20 func Error(cause error, value interface{}, messageArgs ...interface{}) error { 21 return &ex.Ex{ 22 Class: ErrValidation, 23 StackTrace: ex.Callers(ex.DefaultNewStartDepth + 1), 24 Inner: &ValidationError{ 25 Cause: cause, 26 Value: value, 27 Message: fmt.Sprint(messageArgs...), 28 }, 29 } 30 }