mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Undo error cause changes due to broken logic in other places, check for ConflictError explicitly
This commit is contained in:
parent
219714a18e
commit
d8ebfda1bd
2 changed files with 5 additions and 16 deletions
15
pilosa.go
15
pilosa.go
|
|
@ -105,11 +105,6 @@ func NewBadRequestError(err error) BadRequestError {
|
|||
return BadRequestError{err}
|
||||
}
|
||||
|
||||
// Cause satisfies the error causer interface
|
||||
func (e BadRequestError) Cause() error {
|
||||
return e.error
|
||||
}
|
||||
|
||||
// ConflictError wraps an error value to signify that a conflict with an
|
||||
// existing resource occurred such that in an HTTP scenario, http.StatusConflict
|
||||
// would be returned.
|
||||
|
|
@ -122,11 +117,6 @@ func newConflictError(err error) ConflictError {
|
|||
return ConflictError{err}
|
||||
}
|
||||
|
||||
// Cause satisfies the error causer interface
|
||||
func (e ConflictError) Cause() error {
|
||||
return e.error
|
||||
}
|
||||
|
||||
// NotFoundError wraps an error value to signify that a resource was not found
|
||||
// such that in an HTTP scenario, http.StatusNotFound would be returned.
|
||||
type NotFoundError error
|
||||
|
|
@ -145,11 +135,6 @@ func newPreconditionFailedError(err error) PreconditionFailedError {
|
|||
return PreconditionFailedError{err}
|
||||
}
|
||||
|
||||
// Cause satisfies the error causer interface
|
||||
func (e PreconditionFailedError) Cause() error {
|
||||
return e.error
|
||||
}
|
||||
|
||||
// Regular expression to validate index and field names.
|
||||
var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,229}$`)
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func errToStatusError(err error) error {
|
|||
}
|
||||
|
||||
// Check error string.
|
||||
switch errors.Cause(err) {
|
||||
switch cause := errors.Cause(err); cause {
|
||||
case pilosa.ErrIndexNotFound,
|
||||
pilosa.ErrFieldNotFound,
|
||||
pilosa.ErrForeignIndexNotFound,
|
||||
|
|
@ -123,6 +123,10 @@ func errToStatusError(err error) error {
|
|||
pilosa.ErrTooManyWrites,
|
||||
pilosa.ErrNodeIDNotExists:
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
default:
|
||||
if _, ok := cause.(pilosa.ConflictError); ok {
|
||||
return status.Error(codes.AlreadyExists, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return status.Error(codes.Unknown, err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue