mirror of
https://github.com/bytedream/docker4ssh.git
synced 2025-05-09 12:15:11 +02:00
34 lines
738 B
Go
34 lines
738 B
Go
package validate
|
|
|
|
import "fmt"
|
|
|
|
func newValidateError(section, key string, value interface{}, message string, original error) *ValidateError {
|
|
return &ValidateError{
|
|
section: section,
|
|
key: key,
|
|
value: value,
|
|
message: message,
|
|
originalError: original,
|
|
}
|
|
}
|
|
|
|
type ValidateError struct {
|
|
error
|
|
|
|
section string
|
|
key string
|
|
value interface{}
|
|
|
|
message string
|
|
|
|
originalError error
|
|
}
|
|
|
|
func (ve *ValidateError) Error() string {
|
|
if ve.originalError != nil {
|
|
return fmt.Sprintf("failed to validate %s.%s (%v), %s: %v", ve.section, ve.key, ve.value, ve.message, ve.originalError)
|
|
} else {
|
|
return fmt.Sprintf("failed to validate %s.%s (%v), %s", ve.section, ve.key, ve.value, ve.message)
|
|
}
|
|
}
|