ripple-api/app/v1/errors.go

28 lines
636 B
Go
Raw Normal View History

2016-04-03 17:59:27 +00:00
package v1
import (
2016-04-05 20:22:13 +00:00
"strings"
2016-04-03 17:59:27 +00:00
"github.com/osuripple/api/common"
)
// Boilerplate errors
var (
Err500 = common.Response{
2016-04-05 20:22:13 +00:00
Code: 500,
2016-04-03 17:59:27 +00:00
Message: "An error occurred. Try again, perhaps?",
}
2016-04-05 20:22:13 +00:00
ErrBadJSON = common.Response{
Code: 400,
Message: "There was an error processing your JSON data.",
}
2016-04-03 17:59:27 +00:00
)
2016-04-05 20:22:13 +00:00
// ErrMissingField generates a response to a request when some fields in the JSON are missing.
func ErrMissingField(missingFields ...string) common.Response {
return common.Response{
Code: 422, // http://stackoverflow.com/a/10323055/5328069
Message: "Missing fields: " + strings.Join(missingFields, ", ") + ".",
}
}