use private errors do avoid overlapping types among packages
This commit is contained in:
parent
3606f9984d
commit
9475fe4526
|
@ -4,19 +4,19 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// Error allows you to create constant "const" error with type boxing.
|
||||
type Error string
|
||||
// cerr allows you to create constant "const" error with type boxing.
|
||||
type cerr string
|
||||
|
||||
// Error implements the error builtin interface.
|
||||
func (err Error) Error() string {
|
||||
func (err cerr) Error() string {
|
||||
return string(err)
|
||||
}
|
||||
|
||||
// ErrReqParamNotFound is thrown when a request parameter is not found
|
||||
const ErrReqParamNotFound = Error("request parameter not found")
|
||||
const ErrReqParamNotFound = cerr("request parameter not found")
|
||||
|
||||
// ErrReqParamNotType is thrown when a request parameter is not asked with the right type
|
||||
const ErrReqParamNotType = Error("request parameter does not fulfills type")
|
||||
const ErrReqParamNotType = cerr("request parameter does not fulfills type")
|
||||
|
||||
// RequestParam defines input parameters of an api request
|
||||
type RequestParam map[string]interface{}
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
package config
|
||||
|
||||
// Error allows you to create constant "const" error with type boxing.
|
||||
type Error string
|
||||
// cerr allows you to create constant "const" error with type boxing.
|
||||
type cerr string
|
||||
|
||||
// Error implements the error builtin interface.
|
||||
func (err Error) Error() string {
|
||||
func (err cerr) Error() string {
|
||||
return string(err)
|
||||
}
|
||||
|
||||
// ErrRead - a problem ocurred when trying to read the configuration file
|
||||
const ErrRead = Error("cannot read config")
|
||||
const ErrRead = cerr("cannot read config")
|
||||
|
||||
// ErrUnknownMethod - invalid http method
|
||||
const ErrUnknownMethod = Error("unknown HTTP method")
|
||||
const ErrUnknownMethod = cerr("unknown HTTP method")
|
||||
|
||||
// ErrFormat - a invalid format has been detected
|
||||
const ErrFormat = Error("invalid config format")
|
||||
const ErrFormat = cerr("invalid config format")
|
||||
|
||||
// ErrPatternCollision - there is a collision between 2 services' patterns (same method)
|
||||
const ErrPatternCollision = Error("invalid config format")
|
||||
const ErrPatternCollision = cerr("invalid config format")
|
||||
|
||||
// ErrInvalidPattern - a service pattern is malformed
|
||||
const ErrInvalidPattern = Error("must begin with a '/' and not end with")
|
||||
const ErrInvalidPattern = cerr("must begin with a '/' and not end with")
|
||||
|
||||
// ErrInvalidPatternBraceCapture - a service pattern brace capture is invalid
|
||||
const ErrInvalidPatternBraceCapture = Error("invalid uri capturing braces")
|
||||
const ErrInvalidPatternBraceCapture = cerr("invalid uri capturing braces")
|
||||
|
||||
// ErrUnspecifiedBraceCapture - a parameter brace capture is not specified in the pattern
|
||||
const ErrUnspecifiedBraceCapture = Error("capturing brace missing in the path")
|
||||
const ErrUnspecifiedBraceCapture = cerr("capturing brace missing in the path")
|
||||
|
||||
// ErrUndefinedBraceCapture - a parameter brace capture in the pattern is not defined in parameters
|
||||
const ErrUndefinedBraceCapture = Error("capturing brace missing input definition")
|
||||
const ErrUndefinedBraceCapture = cerr("capturing brace missing input definition")
|
||||
|
||||
// ErrMissingDescription - a service is missing its description
|
||||
const ErrMissingDescription = Error("missing description")
|
||||
const ErrMissingDescription = cerr("missing description")
|
||||
|
||||
// ErrIllegalOptionalURIParam - an URI parameter cannot be optional
|
||||
const ErrIllegalOptionalURIParam = Error("URI parameter cannot be optional")
|
||||
const ErrIllegalOptionalURIParam = cerr("URI parameter cannot be optional")
|
||||
|
||||
// ErrMissingParamDesc - a parameter is missing its description
|
||||
const ErrMissingParamDesc = Error("missing parameter description")
|
||||
const ErrMissingParamDesc = cerr("missing parameter description")
|
||||
|
||||
// ErrUnknownDataType - a parameter has an unknown datatype name
|
||||
const ErrUnknownDataType = Error("unknown data type")
|
||||
const ErrUnknownDataType = cerr("unknown data type")
|
||||
|
||||
// ErrIllegalParamName - a parameter has an illegal name
|
||||
const ErrIllegalParamName = Error("illegal parameter name")
|
||||
const ErrIllegalParamName = cerr("illegal parameter name")
|
||||
|
||||
// ErrMissingParamType - a parameter has an illegal type
|
||||
const ErrMissingParamType = Error("missing parameter type")
|
||||
const ErrMissingParamType = cerr("missing parameter type")
|
||||
|
||||
// ErrParamNameConflict - a parameter has a conflict with its name/rename field
|
||||
const ErrParamNameConflict = Error("name conflict for parameter")
|
||||
const ErrParamNameConflict = cerr("name conflict for parameter")
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package multipart
|
||||
|
||||
// Error allows you to create constant "const" error with type boxing.
|
||||
type Error string
|
||||
// cerr allows you to create constant "const" error with type boxing.
|
||||
type cerr string
|
||||
|
||||
// Error implements the error builtin interface.
|
||||
func (err Error) Error() string {
|
||||
func (err cerr) Error() string {
|
||||
return string(err)
|
||||
}
|
||||
|
||||
// ErrMissingDataName is set when a multipart variable/file has no name="..."
|
||||
const ErrMissingDataName = Error("data has no name")
|
||||
const ErrMissingDataName = cerr("data has no name")
|
||||
|
||||
// ErrDataNameConflict is set when a multipart variable/file name is already used
|
||||
const ErrDataNameConflict = Error("data name conflict")
|
||||
const ErrDataNameConflict = cerr("data name conflict")
|
||||
|
||||
// ErrNoHeader is set when a multipart variable/file has no (valid) header
|
||||
const ErrNoHeader = Error("data has no header")
|
||||
const ErrNoHeader = cerr("data has no header")
|
||||
|
||||
// Component represents a multipart variable/file
|
||||
type Component struct {
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
package reqdata
|
||||
|
||||
// Error allows you to create constant "const" error with type boxing.
|
||||
type Error string
|
||||
// cerr allows you to create constant "const" error with type boxing.
|
||||
type cerr string
|
||||
|
||||
// Error implements the error builtin interface.
|
||||
func (err Error) Error() string {
|
||||
func (err cerr) Error() string {
|
||||
return string(err)
|
||||
}
|
||||
|
||||
// ErrUnknownType is returned when encountering an unknown type
|
||||
const ErrUnknownType = Error("unknown type")
|
||||
const ErrUnknownType = cerr("unknown type")
|
||||
|
||||
// ErrInvalidMultipart is returned when multipart parse failed
|
||||
const ErrInvalidMultipart = cerr("invalid multipart")
|
||||
|
||||
// ErrParseParameter is returned when a parameter fails when parsing
|
||||
const ErrParseParameter = cerr("cannot parse parameter")
|
||||
|
||||
// ErrInvalidJSON is returned when json parse failed
|
||||
const ErrInvalidJSON = Error("invalid json")
|
||||
|
||||
// ErrInvalidRootType is returned when json is a map
|
||||
const ErrInvalidRootType = Error("invalid json root type")
|
||||
|
||||
// ErrInvalidParamName - parameter has an invalid
|
||||
const ErrInvalidParamName = Error("invalid parameter name")
|
||||
const ErrInvalidJSON = cerr("invalid json")
|
||||
|
||||
// ErrMissingRequiredParam - required param is missing
|
||||
const ErrMissingRequiredParam = Error("missing required param")
|
||||
const ErrMissingRequiredParam = cerr("missing required param")
|
||||
|
||||
// ErrInvalidType - parameter value does not satisfy its type
|
||||
const ErrInvalidType = Error("invalid type")
|
||||
const ErrInvalidType = cerr("invalid type")
|
||||
|
||||
// ErrMissingURIParameter - missing an URI parameter
|
||||
const ErrMissingURIParameter = Error("missing URI parameter")
|
||||
const ErrMissingURIParameter = cerr("missing URI parameter")
|
||||
|
|
Loading…
Reference in New Issue