mirror of
https://github.com/openziti/ziti.git
synced 2026-09-11 21:38:58 +00:00
6fdd5bcda5
* Add support for multiple terminators to services and sync model abstractions with edge * Add Snapshot to db.Db * Make API friendly errors * Add association querying. Consolidate Entity* interfaces
32 lines
610 B
Go
32 lines
610 B
Go
package models
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
maxFieldErrorValueLength = 20
|
|
)
|
|
|
|
type FieldError struct {
|
|
Reason string
|
|
FieldName string
|
|
FieldValue interface{}
|
|
}
|
|
|
|
func (fe FieldError) Error() string {
|
|
v := fe.FieldValue
|
|
if s, ok := fe.FieldValue.(string); ok {
|
|
if len(s) > maxFieldErrorValueLength {
|
|
v = s[0:maxFieldErrorValueLength] + "..."
|
|
}
|
|
}
|
|
return fmt.Sprintf("the value '%v' for '%s' is invalid: %s", v, fe.FieldName, fe.Reason)
|
|
}
|
|
|
|
func NewFieldError(reason, name string, value interface{}) *FieldError {
|
|
return &FieldError{
|
|
Reason: reason,
|
|
FieldName: name,
|
|
FieldValue: value,
|
|
}
|
|
}
|