use constructors for errors

This commit is contained in:
Travis Turner 2018-07-01 19:54:00 -05:00
parent 9633e34300
commit c0b5ad316d
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
2 changed files with 4 additions and 4 deletions

View file

@ -304,7 +304,7 @@ func (h *Holder) CreateIndex(name string, opt IndexOptions) (*Index, error) {
// Ensure index doesn't already exist.
if h.indexes[name] != nil {
return nil, ConflictError{ErrIndexExists}
return nil, NewConflictError(ErrIndexExists)
}
return h.createIndex(name, opt)
}
@ -374,7 +374,7 @@ func (h *Holder) DeleteIndex(name string) error {
// Confirm index exists.
index := h.index(name)
if index == nil {
return NotFoundError{ErrIndexNotFound}
return NewNotFoundError(ErrIndexNotFound)
}
// Close index.

View file

@ -276,7 +276,7 @@ func (i *Index) CreateField(name string, opt FieldOptions) (*Field, error) {
// Ensure field doesn't already exist.
if i.fields[name] != nil {
return nil, ConflictError{ErrFieldExists}
return nil, NewConflictError(ErrFieldExists)
}
return i.createField(name, opt)
}
@ -349,7 +349,7 @@ func (i *Index) DeleteField(name string) error {
// Confirm field exists.
f := i.field(name)
if f == nil {
return NotFoundError{ErrFieldNotFound}
return NewNotFoundError(ErrFieldNotFound)
}
// Close field.