Chore: use errutil for pluginRepo errors (#78647)

* Chore: use errutil for pluginRepo errors

* Update pkg/util/errutil/status.go

* Use errutil helper functions

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Forgot the log level

* Use entity

---------

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
Gabriel MABILLE
2023-11-30 15:49:27 +01:00
committed by GitHub
parent d64c2b6f4e
commit ef2c79d22a
9 changed files with 121 additions and 68 deletions

View File

@ -55,6 +55,28 @@ func NotFound(msgID string, opts ...BaseOpt) Base {
return NewBase(StatusNotFound, msgID, opts...)
}
// UnprocessableContent initializes a new [Base] error with reason StatusUnprocessableEntity
// that is used to construct [Error]. The msgID is passed to the caller
// to serve as the base for user facing error messages.
//
// msgID should be structured as component.errorBrief, for example
//
// plugin.checksumMismatch
func UnprocessableEntity(msgID string, opts ...BaseOpt) Base {
return NewBase(StatusUnprocessableEntity, msgID, opts...)
}
// Conflict initializes a new [Base] error with reason StatusConflict
// that is used to construct [Error]. The msgID is passed to the caller
// to serve as the base for user facing error messages.
//
// msgID should be structured as component.errorBrief, for example
//
// folder.alreadyExists
func Conflict(msgID string, opts ...BaseOpt) Base {
return NewBase(StatusConflict, msgID, opts...)
}
// BadRequest initializes a new [Base] error with reason StatusBadRequest
// that is used to construct [Error]. The msgID is passed to the caller
// to serve as the base for user facing error messages.