整理代码

This commit is contained in:
2024-03-22 16:10:15 +08:00
committed by Nite07
parent f545848ce1
commit a7ceb4ecb0
16 changed files with 428 additions and 442 deletions

24
parser/error.go Normal file
View File

@@ -0,0 +1,24 @@
package parser
type ParseError struct {
Type ParseErrorType
Message string
Raw string
}
type ParseErrorType string
const (
ErrInvalidPrefix ParseErrorType = "invalid url prefix"
ErrInvalidStruct ParseErrorType = "invalid struct"
ErrInvalidPort ParseErrorType = "invalid port number"
ErrCannotParseParams ParseErrorType = "cannot parse query parameters"
ErrInvalidBase64 ParseErrorType = "invalid base64"
)
func (e *ParseError) Error() string {
if e.Message != "" {
return string(e.Type) + ": " + e.Message + " \"" + e.Raw + "\""
}
return string(e.Type)
}