Skip to content

C#: improve WitException.Value type #1042

@pavelsavara

Description

@pavelsavara

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

Metadata

Metadata

Assignees

Labels

gen-c#Related to the C# code generator

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions