Closed elboletaire closed 4 months ago
At this moment is not possible to fix it in anyway on the explorer because the fetch election method throw an exception, making it impossible to instantiate an InvalidElection.
At this moment is not possible to fix it in anyway on the explorer because the fetch election method throw an exception, making it impossible to instantiate an InvalidElection.
That's true. And it made me think...
An intermediate implementation to not break backwards compatibility would be to throw the InvalidElection
somehow (this way old implementations would still crash, and anyone wanting to grab that InvalidElection
could do so via the catch of the throwing method).
Describe the feature
Right now, the
InvalidElection
can only be returned by thefetchElections
(plural) method. I'd like that any method that can return an election (usually PublishedElection or ArchivedElection), handles invalid elections returning anInvalidElection
instance, rather than crashing as they do now (like withfetchElection
[singular]).Motivation
The real motivation is the new explorer, where we'd like to show the election view for invalid elections as well as for valid ones, allowing users and developers to access the raw data button that's in such view.
In the explorer @selankon is working to manage this on our own, but it's something I've pending for the ui-scaffold, so other projects could benefit from it too.
You have an invalid election currently in stg, in case you want to have one by hand: https://vocdoni-explorer-stg.netlify.app/process/b31dff61814d0e39f9b3bf2b71bc37a8bb312f6c4d8965f1406f030800000000
Proposal
I'm not sure how the "raw" data is managed in InvalidElections, but checking the code it seems to me thy only accept an id. I'd recommend adding some way to put the raw data in there for an advanced analysis of the election object.
Components affected
Any currently returning elections but crashing for invalid ones rather than returning a
InvalidElection
instance.