37 lines
868 B
Go
37 lines
868 B
Go
package domain
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
ErrorCodeBadRequest = 400
|
|
ErrorCodeModuleNotFound = 2001
|
|
ErrorCodeConfigNotFound = 2002
|
|
ErrorCodeInvalidConfig = 2003
|
|
ErrorCodeConfigVersionConflict = 2004
|
|
ErrorCodeSchemaNotFound = 2005
|
|
ErrorCodeVariableNotFound = 2006
|
|
ErrorCodeVariableAlreadyExists = 2007
|
|
ErrorCodeVariableUsedInConfigs = 2008
|
|
)
|
|
|
|
type ConfigValidationError struct {
|
|
Details map[string]string
|
|
}
|
|
|
|
func NewConfigValidationError(details map[string]string) ConfigValidationError {
|
|
return ConfigValidationError{
|
|
Details: details,
|
|
}
|
|
}
|
|
|
|
func (e ConfigValidationError) Error() string {
|
|
descriptions := make([]string, 0, len(e.Details))
|
|
for field, err := range e.Details {
|
|
descriptions = append(descriptions, fmt.Sprintf("%s -> %s", field, err))
|
|
}
|
|
return strings.Join(descriptions, "; ")
|
|
}
|