Merge pull request #63 from lbryio/declare_err
Add undeclared errors from peer.go to metrics
This commit is contained in:
commit
0dfda70c70
2 changed files with 13 additions and 1 deletions
|
@ -86,9 +86,13 @@ const (
|
||||||
errUnexpectedEOFStr = "unexpected_eof_str"
|
errUnexpectedEOFStr = "unexpected_eof_str"
|
||||||
errJSONSyntax = "json_syntax"
|
errJSONSyntax = "json_syntax"
|
||||||
errBlobTooBig = "blob_too_big"
|
errBlobTooBig = "blob_too_big"
|
||||||
|
errInvalidPeerJSON = "invalid_peer_json"
|
||||||
errInvalidPeerData = "invalid_peer_data"
|
errInvalidPeerData = "invalid_peer_data"
|
||||||
|
errRequestTooLarge = "request_too_large"
|
||||||
errDeadlineExceeded = "deadline_exceeded"
|
errDeadlineExceeded = "deadline_exceeded"
|
||||||
errHashMismatch = "hash_mismatch"
|
errHashMismatch = "hash_mismatch"
|
||||||
|
errProtectedBlob = "protected_blob"
|
||||||
|
errInvalidBlobHash = "invalid_blob_hash"
|
||||||
errZeroByteBlob = "zero_byte_blob"
|
errZeroByteBlob = "zero_byte_blob"
|
||||||
errInvalidCharacter = "invalid_character"
|
errInvalidCharacter = "invalid_character"
|
||||||
errBlobNotFound = "blob_not_found"
|
errBlobNotFound = "blob_not_found"
|
||||||
|
@ -297,12 +301,20 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
|
||||||
} else if strings.Contains(err.Error(), "blob must be at most") {
|
} else if strings.Contains(err.Error(), "blob must be at most") {
|
||||||
//log.Warnln("blob must be at most X bytes is not the same as ErrBlobTooBig")
|
//log.Warnln("blob must be at most X bytes is not the same as ErrBlobTooBig")
|
||||||
errType = errBlobTooBig
|
errType = errBlobTooBig
|
||||||
|
} else if strings.Contains(err.Error(), "invalid json request") {
|
||||||
|
errType = errInvalidPeerJSON
|
||||||
} else if strings.Contains(err.Error(), "Invalid data") {
|
} else if strings.Contains(err.Error(), "Invalid data") {
|
||||||
errType = errInvalidPeerData
|
errType = errInvalidPeerData
|
||||||
|
} else if strings.Contains(err.Error(), "request is too large") {
|
||||||
|
errType = errRequestTooLarge
|
||||||
|
} else if strings.Contains(err.Error(), "Invalid blob hash length") {
|
||||||
|
errType = errInvalidBlobHash
|
||||||
} else if strings.Contains(err.Error(), "hash of received blob data does not match hash from send request") {
|
} else if strings.Contains(err.Error(), "hash of received blob data does not match hash from send request") {
|
||||||
errType = errHashMismatch
|
errType = errHashMismatch
|
||||||
} else if strings.Contains(err.Error(), "blob not found") {
|
} else if strings.Contains(err.Error(), "blob not found") {
|
||||||
errType = errBlobNotFound
|
errType = errBlobNotFound
|
||||||
|
} else if strings.Contains(err.Error(), "requested blob is protected") {
|
||||||
|
errType = errProtectedBlob
|
||||||
} else if strings.Contains(err.Error(), "0-byte blob received") {
|
} else if strings.Contains(err.Error(), "0-byte blob received") {
|
||||||
errType = errZeroByteBlob
|
errType = errZeroByteBlob
|
||||||
} else if strings.Contains(err.Error(), "PROTOCOL_VIOLATION: tried to retire connection") {
|
} else if strings.Contains(err.Error(), "PROTOCOL_VIOLATION: tried to retire connection") {
|
||||||
|
|
|
@ -227,7 +227,7 @@ func (s *Server) handleCompositeRequest(data []byte) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var je *json.SyntaxError
|
var je *json.SyntaxError
|
||||||
if ee.As(err, &je) {
|
if ee.As(err, &je) {
|
||||||
return nil, errors.Err("invalid json at offset %d in data %s", je.Offset, hex.EncodeToString(data))
|
return nil, errors.Err("invalid json request: offset %d in data %s", je.Offset, hex.EncodeToString(data))
|
||||||
}
|
}
|
||||||
return nil, errors.Err(err)
|
return nil, errors.Err(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue