Today to unpack these, it seems like you have to use the individual instanceOf methods:
catch (err) {
if (RegisterAccountError.WeakPassword.instanceOf(err)) {
// process
} else if (RegisterAccountError.EmailAlreadyInUse.instanceOf(err)) {
//proces
} // etc
}
It would be nice if there was some kind of generated typescript enum that could be matched against in Typescript for these, to help ensure you are exhaustive in your type checking. I would imagine it was like the tag that is used for other Enums in the system, something like this:
catch (err) {
if (RegisterAccountError.instanceOf(err)) {
switch(err.tag) {
case RegisterAccountErrorTag.WeakPassword:
// stuff
break;
case RegisterAccountErrorTag.EmailAlreadyInUse:
// more stuff
break;
default:
}
}
I know Errors can be a bit of an 'anything' in rust, which makes it hard to bridge to typescript. But I was thinking maybe the flat_error marker could be something we key off of here?
In the uniffi exposed library we are using, it seems like the use of the flat_error definition is fairly common:
Today to unpack these, it seems like you have to use the individual instanceOf methods:
It would be nice if there was some kind of generated typescript enum that could be matched against in Typescript for these, to help ensure you are exhaustive in your type checking. I would imagine it was like the tag that is used for other Enums in the system, something like this:
I know Errors can be a bit of an 'anything' in rust, which makes it hard to bridge to typescript. But I was thinking maybe the flat_error marker could be something we key off of here?