we have fixtures ladies and gentleman
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func IsBadRequest(err error) bool {
|
||||
return strings.HasPrefix(err.Error(), "bad request:")
|
||||
return strings.Contains(err.Error(), "bad request:")
|
||||
}
|
||||
|
||||
func BadRequest(err string) error {
|
||||
@@ -18,14 +18,14 @@ func BadRequestNotFound(resource, field string, value any) error {
|
||||
return BadRequest(errStr)
|
||||
}
|
||||
|
||||
func BadRequestNotAssociated(parent, child string, parentID, childID any) error {
|
||||
errStr := fmt.Sprintf("%s (ID: %v) not associated with %s (ID: %v)",
|
||||
child, childID, parent, parentID)
|
||||
func BadRequestNotAssociated(parent, child, parentField, childField string, parentID, childID any) error {
|
||||
errStr := fmt.Sprintf("%s with %s=%v not associated to %s with %s=%v",
|
||||
child, childField, childID, parent, parentField, parentID)
|
||||
return BadRequest(errStr)
|
||||
}
|
||||
|
||||
func BadRequestAssociated(parent, child string, parentID, childID any) error {
|
||||
errStr := fmt.Sprintf("%s (ID: %v) already associated with %s (ID: %v)",
|
||||
child, childID, parent, parentID)
|
||||
func BadRequestAssociated(parent, child, parentField, childField string, parentID, childID any) error {
|
||||
errStr := fmt.Sprintf("%s with %s=%v already associated to %s with %s=%v",
|
||||
child, childField, childID, parent, parentField, parentID)
|
||||
return BadRequest(errStr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user