Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: report partial batch instruction processing error #8063

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

jeremyletang
Copy link
Member

close #7843

@jeremyletang jeremyletang requested a review from a team as a code owner April 3, 2023 09:54
@edd
Copy link
Member

edd commented Apr 3, 2023

This will be great for block explorer! I can't add much to the review though. New status code looks good.

AnExsomnis
AnExsomnis previously approved these changes Apr 3, 2023
@jeremyletang
Copy link
Member Author

Can you make the wallet aware of this new status code and handle it appropriately:

func (s *API) writeTxError(w http.ResponseWriter, r *api.SubmitTransactionResponse) {
	var code int
	switch r.Code {
	case TxnSpamError:
		code = http.StatusTooManyRequests
	case TxnUnknownCommandError, TxnValidationFailure, TxnDecodingFailure:
		code = http.StatusBadRequest
	case TxnInternalError:
		code = http.StatusInternalServerError
	default:
		s.log.Error("unknown transaction code", zap.Uint32("code", r.Code))
		code = http.StatusInternalServerError
	}
	s.writeError(w, newErrorResponse(r.Data), code)
}

hum yes. Any thoughts on what http status code would work well for this?

@wwestgarth
Copy link
Contributor

Can you make the wallet aware of this new status code and handle it appropriately:

func (s *API) writeTxError(w http.ResponseWriter, r *api.SubmitTransactionResponse) {
	var code int
	switch r.Code {
	case TxnSpamError:
		code = http.StatusTooManyRequests
	case TxnUnknownCommandError, TxnValidationFailure, TxnDecodingFailure:
		code = http.StatusBadRequest
	case TxnInternalError:
		code = http.StatusInternalServerError
	default:
		s.log.Error("unknown transaction code", zap.Uint32("code", r.Code))
		code = http.StatusInternalServerError
	}
	s.writeError(w, newErrorResponse(r.Data), code)
}

hum yes. Any thoughts on what http status code would work well for this?

I deleted my comment because I realised it didn't really matter. The error only comes through at delivering and not checking, so the wallet would never see it anyway.

Signed-off-by: Jeremy Letang <me@jeremyletang.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clearer error coding for batch orders
4 participants