Return descriptive error if ticket cannot be broadcast
This commit is contained in:
parent
4a207b15f8
commit
8c428c769d
@ -23,6 +23,7 @@ const (
|
||||
errInvalidPrivKey
|
||||
errFeeNotReceived
|
||||
errInvalidTicket
|
||||
errCannotBroadcastTicket
|
||||
)
|
||||
|
||||
// httpStatus maps application error codes to HTTP status codes.
|
||||
@ -56,6 +57,8 @@ func (e apiError) httpStatus() int {
|
||||
return http.StatusBadRequest
|
||||
case errInvalidTicket:
|
||||
return http.StatusBadRequest
|
||||
case errCannotBroadcastTicket:
|
||||
return http.StatusInternalServerError
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
@ -92,6 +95,8 @@ func (e apiError) defaultMessage() string {
|
||||
return "no fee tx received for ticket"
|
||||
case errInvalidTicket:
|
||||
return "not a valid ticket tx"
|
||||
case errCannotBroadcastTicket:
|
||||
return "ticket transaction could not be broadcast"
|
||||
default:
|
||||
return "unknown error"
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ func broadcastTicket() gin.HandlerFunc {
|
||||
if err != nil {
|
||||
log.Errorf("%s: dcrd.SendRawTransaction for ticket failed (ticketHash=%s): %v",
|
||||
funcName, request.TicketHash, err)
|
||||
sendError(errInternalError, c)
|
||||
sendError(errCannotBroadcastTicket, c)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user