Open sam0x17 opened 3 months ago
Synced with the @opentensor/cortex peeps, this is how we will pass it to them:
We will add an RPC call that produces a JSON map of all error codes => { name, description } for each error. Client will hold off on calling this RPC endpoint until the first time they encounter an error, then they will hit the endpoint and cache the map (probably in a local file). Later, if they ever hit an error code that isn't in their local map, they will hit the endpoint again. In this way, we will always be able to display names and descriptions for errors coming from subtensor, even if new ones are introduced in a chain upgrade that bittensor doesn't specifically know about.
cc @unconst ^
so data coming back from that endpoint will look something like:
{
"0": {
"name": "SomeError",
"description": "Thrown when yeet and something something"
},
"1": {
"name": "AnotherError",
"description": "This is a description something something"
},
"2": {
"name": "YetAnotherError",
"description": "This is a description something something"
}
}
I would recommend doing something like this rather than Display
actually:
pub trait SubtensorError {
const NAME: &'static str;
const DESCRIPTION: &'static str;
}
Related : https://github.com/opentensor/subtensor/issues/375 cc @camfairchild
partially fixed by #391
right now it looks like the way forward is actually just using regular substrate metadata, which @open-junius has implemented in #391
From this unit test file for metadata, the structure is clear for other language like python to parse. https://github.com/opentensor/subtensor/blob/development/runtime/tests/metadata.rs
It's pretty annoying that the UI doesn't know at all what errors are if they haven't been hard-coded. Unknown error isn't a great user experience, and right now introducing new error types or errors in new situations creates a lot of churn with releases.
Substrate provides the metadata, which includes all info about errors, calls and events. At first, we must guarantee all of them are well documented. In this issue, all docs for errors are checked.
From this unit test file for metadata check, the structure is clear for other language like python and js to parse. https://github.com/opentensor/subtensor/blob/development/runtime/tests/metadata.rs
fixes #375