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

API: propagate errors to single-response APIs #277

Merged
merged 5 commits into from
Apr 9, 2019
Merged

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Apr 8, 2019

Now callers of single response APIs will be able to catch errors from the call that are propagated through @aragon/wrapper.

They can either do this by including an error handler to their .subscribe() or by turning the returned observable into a promise and using the standard promise-rejection handling methods.

A good example of where this is useful is for transaction signing and message signing, where the user may ultimately reject or cancel the intent.

@sohkai sohkai requested a review from 2color April 8, 2019 18:36
filter((message) => message.id === id)
filter((message) => message.id === id),
map((response) => {
if (response.error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to leave the response.error an error instance in https://github.com/aragon/aragon.js/blob/master/packages/aragon-rpc-messenger/src/jsonrpc.js#L19?

It seems like we are converting an error to a string in jsonrpc.js and back to an error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Primarily because sending an Error instance through postMessage() will fail: see things that don't work with the structured clone algorithm.

@sohkai sohkai mentioned this pull request Apr 9, 2019
1 task
@2color 2color self-requested a review April 9, 2019 13:36
@sohkai sohkai merged commit 4914b59 into master Apr 9, 2019
@sohkai sohkai deleted the api-propagate-error branch April 9, 2019 14:25
sohkai added a commit to aragon/client that referenced this pull request Apr 10, 2019
…entity modification (#686)

Coupled with aragon/aragon.js#277, apps will now receive errors on `requestAddressIdentityModification()`.
sohkai added a commit to aragon/aragon-apps that referenced this pull request Apr 18, 2019
Fixes aragon/client#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive `token.symbol()` on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.
2color added a commit to 2color/aragon.js that referenced this pull request Apr 26, 2019
…th-cache

* origin/master: (29 commits)
  Update README.md (aragon#291)
  Wrapper: clarify comments about forwarding path finding strategy (aragon#289)
  Split quick start doc from intro (aragon#287)
  @aragon/wrapper 5.0.0-rc.2
  wrapper: prettify setApp() descriptions (aragon#284)
  wrapper: fix callsscripts decoding (aragon#283)
  Wrapper: add installedRepos observable (aragon#268)
  fix: avoid infinitely looping through forwarders when looking for a transaction path (aragon#285)
  wrapper: enforce message to sign is string (aragon#282)
  api: v1.1.0
  rpc-messenger: v1.1.0
  feat: @aragon/wrapper api cleanup (aragon#279)
  Wrapper: handle SetApp for updated apps (aragon#267)
  feat: Add message signing (aragon#276)
  Wrapper: don't assign initializationBlock on non-kernel proxies when unneeded (aragon#266)
  chore: ignore package-lock.jsons (aragon#280)
  API: propagate errors to single-response APIs (aragon#277)
  Rpc Messenger: dedupe message bus across requests (aragon#278)
  Fix: changes after review (aragon#274)
  Docs update: include react api, aragon app architecture & fixes (aragon#271)
  ...
nickhabets added a commit to nickhabets/aragon that referenced this pull request Dec 29, 2020
Fixes aragon/client#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive `token.symbol()` on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.
nickhabets pushed a commit to nickhabets/aragon that referenced this pull request Dec 29, 2020
Fixes aragon/client#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive `token.symbol()` on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
Fixes aragon/client#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive `token.symbol()` on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.
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.

2 participants