Return descriptive error if ticket cannot be broadcast

This commit is contained in:
jholdstock 2020-08-18 16:57:03 +01:00 committed by David Hill
parent 4a207b15f8
commit 8c428c769d
2 changed files with 6 additions and 1 deletions

View File

@ -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"
}

View File

@ -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 {