The Telerik Platform product is retired.Learn more

Exception Handling

Exception Handling

Handling errors is a normal part of coding any application, especially an ever-connected app. Depending on the .NET execution methods you use, you do this differently.

This article is organized as follows:

When Using Execute Methods

You can handle errors using try...catch blocks around the invocation when using Execute, ExecuteSync or ExecuteAsync.

try
{
    var allBooks = await app.WorkWith().Data<Book>().GetAll().ExecuteAsync();
}
catch (EverliveException ex)
{
    ...
}

When Using TryExecute Methods

The TryExecute, TryExecuteAsync, and TryExecuteSync methods allow you to handle errors without a try...catch block. Instead of the actual request result, they return an object that holds either the actual result or the error that occurred.

var allBooksResult = await app.WorkWith().Data<Book>().GetAll().TryExecuteAsync();
if (allBooksResult.Success) {
    var allBooks = allBooksResult.Result;
} else {
    EverliveException error = allBooksResult.Error;
}

The EverliveException Class

Whenever an error occurs while using the SDK, the EverliveException exception is thrown or instantiated. It contains the following members that provide information about the error.

  • Code—an integer value specifying the error code. Use it to build additional error handling logic in your application.
  • Message—a string describing the error. It is not recommended to directly display this message to your app users, but you can log it somewhere for your own reference.

See Also

Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2018, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.