wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

C#: improve WitException.Value type

Open pavelsavara opened this issue 1 year ago • 0 comments

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

pavelsavara avatar Aug 29 '24 10:08 pavelsavara