joinmarket-webui / jam

Your sats. Your privacy. Your profit.
https://jamapp.org
MIT License
264 stars 54 forks source link

More detailed error messages #252

Open ghost opened 2 years ago

ghost commented 2 years ago

See https://github.com/joinmarket-webui/joinmarket-webui/pull/242.

theborakompanioni commented 2 years ago

Assigned myself to this.

Currently, whenever an error is returned by the api, something like this is done:

await Api.getWalletUtxos(requestContext)
      .then((res) =>
        res.ok ? res.json() : Api.Helper.throwError(res, t('global.errors.error_reloading_wallet_failed'))
      )
[...]

However, the second param to throwError is just a "fallback reason". When JM provides a reason, it sometimes is just a generic phrase like Processing failed. Hence, an improvement would be, if the returned reason was wrapped with a more specific error, which should be known because of the context in was called in. Here, it might be something like Error while reloading wallet. Reason: Processing failed.

e.g.

await Api.getWalletUtxos(requestContext)
      .then((res) =>
        res.ok ? res.json() : Api.Helper.throwWrapped(res, {
          message: t('global.errors.error_reloading_wallet_failed'),
          fallback: t('global.errors.reason_unknown')
        }))
      )
[...]