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

Improve takeoffer error handing #5294

Merged
merged 8 commits into from
Mar 19, 2021

Conversation

ghubstan
Copy link
Contributor

UI specific task runner validation errors cannot be passed to the client via a typical ErrorMessageHandler. This change uses a new GrpcErrorMessageHandler implementation that places an optional AvailabilityResult in the takeoffer response if an offer is not available. The client can derive a better failure reason message from the reply's AvailabilityResult.

  • GrpcErrorMessageHandler Add new ErrorMessageHandler implementation to get around the api specific problem of having to use an interface that is designed to build task error messages for the UI.

  • GrpcExceptionHandler Add a method for working with the ErrorMessageHandler interface.

  • GrpcTradesService, CoreApi, CoreTradesService: Adjust the takeoffer error handling to give a failure reason provided by the new GrpcErrorMessageHandler.

  • pb.proto Add PRICE_CHECK_FAILED to enum AvailabilityResult.

  • grpc.proto Add enum AvailabilityResult to TakeOfferReply message. This field is populated by the GrpcErrorMessageHandler when takeoffer fails, making it easier to give CLI users a stylistically consistent failure reason.

  • OpenOfferManager Inject CoreContex to know isApiUser. Set AvailabilityResult = PRICE_CHECK_FAILED if isApiUser=true, leaving it as UNKNOWN_FAILURE for isApiUser=false.

  • OpenOfferManagerTest Adjusted to new CoreContext constructor arg.

  • GrpcClient Adjusted takeOffer to convert AvailabilityResult to user error message if the call fails -- does not return a trade.

  • Added grpc exception catch blocks missing from some api test cases in apitest/src/test/java/bisq/apitest/method/trade.

- Add PRICE_CHECK_FAILED to enum AvailabilityResult.
- Add enum AvailabilityResult to TakeOfferReply message.
- GrpcErrorMessageHandler  A new ErrorMessageHandler implementation
  to get around the api specific problem of having to use Task
  ErrorMessageHandlers that build task error messages for the UI.

- GrpcExceptionHandler  A new method for working with the
  ErrorMessageHandler interface.

- GrpcTradesService, CoreApi, CoreTradesService:  Ajdusted takeoffer
  error handling to give a failure reason provided by the new
  GrpcErrorMessageHandler.
@ghubstan
Copy link
Contributor Author

PR #5292 should be reviewed and merged before this one.

@ghubstan ghubstan changed the title Improve takeoffer error handing [WIP] Improve takeoffer error handing Mar 10, 2021
@ghubstan ghubstan marked this pull request as draft March 10, 2021 17:48
@ghubstan ghubstan changed the title [WIP] Improve takeoffer error handing Improve takeoffer error handing Mar 10, 2021
@ghubstan ghubstan marked this pull request as ready for review March 10, 2021 18:09
Copy link
Contributor

@wallclockbuilder wallclockbuilder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests passing.
LGTM.

ACK

- Add description msg TakeOfferReply proto, and fromProto method
  to core.offer.enum AvailabilityResult.  The description field
  maps a client usable error message to the enum.

- Adjust GrpcErrorMessageHandler to add AvailabilityResult.description()
  to takeoffer reply.

- Refactor (split up) GrpcClient's takeOffer.  Add getTakeOfferReply()
  to give clients a chance to make choices based on the reply's
  AvailabilityResult when the takeoffer command did not result in a
  trade. (Some errors are fatal, some not.)
UNCONF_TX_LIMIT_HIT,
MAKER_DENIED_API_USER
MAKER_DENIED_API_USER,
PRICE_CHECK_FAILED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, this would fail to parse by old clients and thus use the first element in the enum, which is UNKNOWN_FAILURE, which makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed this by sending protobuf.AvailabilityResult.PRICE_CHECK_FAILED(13) to a client that does not have that proto enum value, and the client received UNKNOWN_ENUM_VALUE_AvailabilityResult_13.

@ripcurlx ripcurlx added this to the v1.6.0 milestone Mar 17, 2021
Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sqrrm sqrrm merged commit 1c3fc41 into bisq-network:master Mar 19, 2021
@ghubstan ghubstan deleted the 01-fix-takeoffer-err-handling branch March 19, 2021 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants