Skip to main content

Result handling | .NET MAUI Document Scanner

Starting with SDK version 8.0.0, new classes, Result and Result<T>, have been introduced to represent operation results without throwing exceptions by default. Result represents an outcome without a return value, while Result<T> represents an outcome that may contain a value of generic type T.

On success, IsSuccess is true and (for Result<T>) the returned data is available via Value (or ValueOrNull).

On failure, IsSuccess is false and the underlying platform/native error is exposed via Error. The SDK may mark the result as canceled via IsCanceled when the operation is canceled by closing a RTU UI screen.

Accessing Result<T>.Value will return the value when successful; otherwise it throws the stored Error exception.

The Error property can be mapped to a specific exception type from the list below:

  UnknownException
InvalidLicenseException
NullReferenceException
InvalidArgumentException
InvalidImageRefError
ComponentUnavailableError
IllegalStateException
IOException
InvalidDataException
OperationCanceledException
OutOfMemoryException
TimeoutException
InvalidOperationException

What does this mean in practice? It means you can now handle results in the way that best fits your project. For example:

Handle result using IsSuccess
loading...
Handle result using ValueOrNull
loading...

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license