Forum Cross Platform with Xamarin

A REST-ful discussion

johanksonjohankson SEInsider, University ✭✭

Consider the following pseudo code

   try
{
    var obj = _restClient.Get<Stuff>(stuffArgument, anotherArgument);
}
catch(RestValidationException ex)
{
    MarkFieldsAsInvalid(ex);
}
catch(RestException ex)
{
    Alert("Something undetermined went wrong");
}

Is this a good way to be restful and handle validation and other exceptions?

I've seen so many variants on how to error handle rest calls and they all have pros and cons. The example is a little bit fluffy but in I could imagen that it fetches some undetermined entity called Stuff based on two input fields and if one or more of them are wrong I want a validation exception.

How would you write the same piece of code?

// Johan

Tagged:
Sign In or Register to comment.