Implement api
This commit is contained in:
1 parent
c6148a1c1c
commit
cddd3383e8
10 files changed
+334
-24
No files matched your search
+30
-2
@@ -1,5 +1,33 @@
|
||||
package domain
|
||||
|
||||
const (
|
||||
ErrorCodeBadRequest = 400
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorCodeBadRequest = 400
|
||||
ErrorCodeModuleNotFound = 2001
|
||||
ErrorCodeConfigNotFound = 2002
|
||||
ErrorCodeInvalidConfig = 2003
|
||||
ErrorCodeConfigVersionConflict = 2004
|
||||
ErrorCodeSchemaNotFound = 2005
|
||||
)
|
||||
|
||||
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, "; ")
|
||||
}
|
||||
Reference in new issue
Block a user