wit-bindgen
wit-bindgen copied to clipboard
C#: improve WitException.Value type
The pattern where the user code needs to correctly guess type of the ex.Value is fragile.
catch (WitException e)
{
var error = HeaderErrorToString((HeaderError)e.Value);
throw new HttpRequestException($"Header validation error: {error}");
}
The cast here could throw invalid cast exception or could give misleading information.
Should we generate WitHeaderException and make the conversion on behalf of the user ?
cc @jsturtevant @dicej