decidim-vocdoni / decidim-module-vocdoni

(WIP) A module for Decidim that brings an elections component based on the Vocdoni SDK and API
GNU Affero General Public License v3.0
8 stars 0 forks source link

Show the clear error message when setting the election #62

Closed antopalidi closed 6 months ago

antopalidi commented 1 year ago

When the admin clicks the "Setup election" button, there may be an error in the console that has nothing to do with the election settings. And the user cannot change anything to resolve it.

For example: RESULT => ERROR! vochain replied with error code: (1) checkTx newProcessTx: not enough balance to transfer: required 5153998, got 1000

We need to catch such errors and show another message to the user who creates the election:

Screenshot 2023-06-26 at 11 47 06

andreslucena commented 1 year ago

Great! A couple things regarding this:

  1. I'd also add the SDK version so it's easier to check
  2. Regarding the JSON that we show now with the error, it was suggested that we should use the same configuration that's sent to the Vocdoni API in the same format, so it's easier to debug. This is how I've done it:

Using the election object from https://github.com/decidim-vocdoni/decidim-module-vocdoni/blob/c1885a8bcb8aac5f5616de7ed402c464314b933b/app/packs/src/decidim/vocdoni/admin/utils/create_vocdoni_election.js#L75

As there's a problem with JSON and BigInts (you'll have an exception Uncaught TypeError: BigInt value can't be serialized in JSON) you will need to hack BigInt's JSON representation for this to work:

BigInt.prototype.toJSON = function() { return this.toString() }
JSON.stringify(election)
microstudi commented 6 months ago

Closing this as it is heavily outdated