integrate errors
This commit is contained in:
parent
1b935868b6
commit
93abfc41fc
1 changed files with 84 additions and 0 deletions
|
@ -283,6 +283,34 @@ func (err *ErrListCannotBelongToAPseudoNamespace) HTTPError() web.HTTPError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrListMustBelongToANamespace represents an error where a list must belong to a namespace
|
||||||
|
type ErrListMustBelongToANamespace struct {
|
||||||
|
ListID int64
|
||||||
|
NamespaceID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsErrListMustBelongToANamespace checks if an error is a list must belong to a namespace error.
|
||||||
|
func IsErrListMustBelongToANamespace(err error) bool {
|
||||||
|
_, ok := err.(*ErrListMustBelongToANamespace)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err *ErrListMustBelongToANamespace) Error() string {
|
||||||
|
return fmt.Sprintf("List must belong to a namespace [ListID: %d, NamespaceID: %d]", err.ListID, err.NamespaceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrCodeListMustBelongToANamespace holds the unique world-error code of this error
|
||||||
|
const ErrCodeListMustBelongToANamespace = 3010
|
||||||
|
|
||||||
|
// HTTPError holds the http error description
|
||||||
|
func (err *ErrListMustBelongToANamespace) HTTPError() web.HTTPError {
|
||||||
|
return web.HTTPError{
|
||||||
|
HTTPCode: http.StatusPreconditionFailed,
|
||||||
|
Code: ErrCodeListMustBelongToANamespace,
|
||||||
|
Message: "This list must belong to a namespace.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ================
|
// ================
|
||||||
// List task errors
|
// List task errors
|
||||||
// ================
|
// ================
|
||||||
|
@ -791,6 +819,62 @@ func (err ErrInvalidTaskFilterValue) HTTPError() web.HTTPError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrAttachmentDoesNotBelongToTask represents an error where the provided task cover attachment does not belong to the same task
|
||||||
|
type ErrAttachmentDoesNotBelongToTask struct {
|
||||||
|
TaskID int64
|
||||||
|
AttachmentID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsErrAttachmentAndCoverMustBelongToTheSameTask checks if an error is ErrAttachmentDoesNotBelongToTask.
|
||||||
|
func IsErrAttachmentAndCoverMustBelongToTheSameTask(err error) bool {
|
||||||
|
_, ok := err.(ErrAttachmentDoesNotBelongToTask)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err ErrAttachmentDoesNotBelongToTask) Error() string {
|
||||||
|
return fmt.Sprintf("Task attachment and cover image do not belong to the same task [TaskID: %d, AttachmentID: %d]", err.TaskID, err.AttachmentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrCodeAttachmentDoesNotBelongToTask holds the unique world-error code of this error
|
||||||
|
const ErrCodeAttachmentDoesNotBelongToTask = 4020
|
||||||
|
|
||||||
|
// HTTPError holds the http error description
|
||||||
|
func (err ErrAttachmentDoesNotBelongToTask) HTTPError() web.HTTPError {
|
||||||
|
return web.HTTPError{
|
||||||
|
HTTPCode: http.StatusBadRequest,
|
||||||
|
Code: ErrCodeAttachmentDoesNotBelongToTask,
|
||||||
|
Message: "This attachment does not belong to that task.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrUserAlreadyAssigned represents an error where the user is already assigned to this task
|
||||||
|
type ErrUserAlreadyAssigned struct {
|
||||||
|
TaskID int64
|
||||||
|
UserID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsErrUserAlreadyAssigned checks if an error is ErrUserAlreadyAssigned.
|
||||||
|
func IsErrUserAlreadyAssigned(err error) bool {
|
||||||
|
_, ok := err.(ErrUserAlreadyAssigned)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err ErrUserAlreadyAssigned) Error() string {
|
||||||
|
return fmt.Sprintf("User is already assigned to task [TaskID: %d, UserID: %d]", err.TaskID, err.UserID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrCodeUserAlreadyAssigned holds the unique world-error code of this error
|
||||||
|
const ErrCodeUserAlreadyAssigned = 4021
|
||||||
|
|
||||||
|
// HTTPError holds the http error description
|
||||||
|
func (err ErrUserAlreadyAssigned) HTTPError() web.HTTPError {
|
||||||
|
return web.HTTPError{
|
||||||
|
HTTPCode: http.StatusBadRequest,
|
||||||
|
Code: ErrCodeUserAlreadyAssigned,
|
||||||
|
Message: "This user is already assigned to that task.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =================
|
// =================
|
||||||
// Namespace errors
|
// Namespace errors
|
||||||
// =================
|
// =================
|
||||||
|
|
Loading…
Reference in a new issue