.NET Error Handling¶
The Enfonica .NET Client is a gRPC client. Exceptions that are thrown when calling the API can be handled by catching the RpcException
exception type. You can use C#'s exception filters feature to declare separate catch blocks for different status codes, as shown in the following example.
try
{
var call = await client.GetCallAsync("projects/my-project/calls/saud8ajs8dasj8dasud9a8udk");
}
catch (RpcException ex) when (ex.StatusCode == StatusCode.NotFound)
{
Console.WriteLine("Resource not found");
}
catch (RpcException)
{
Console.WriteLine("Other API error");
}