![]() Result.OnFailure((exception, errs) => Console.WriteLine($"Exception: ") įor more detailed examples and usage information related to asynchronous operations, please refer to the sections on Performing Actions on Success, Handling Failures and Exceptions, Switching Between Success and Failure Actions, Transform the Result Based on Success or Failure, and Mapping a Result to Another Type in this README. If you want to handle failures, you can use the OnFailure or OnException method to perform an action when the result is unsuccessful: Imagine you have a method that returns a result,you can use the OnSuccess method to execute an action only when the result is successful. Var exception = result.ExceptionOrNull() if IsFailure = false => exception is null and Errors is empty Var personWithCustomDefault = result.GetOrDefault(new Person("custom")) Result failure = new InvalidOperationException() Var failureResultException = Result.Fail(new InvalidOperationException(),"An error occurred") Var failureResultException = Result.Fail(new InvalidOperationException()) Var failureResultErors = Result.Fail("An error occurred","Another error occurred") Var failureResultWithValue = Result.Fail("An error occurred") Var failureResult = Result.Fail("An error occurred") Make Result var successResult = Result.Success() The following sections demonstrate various ways to use the SimpleResult library for handling the results of operations. ![]() NET Core command line interface: dotnet add package Arax.SimpleResult You should install SimpleResult with NuGet: Install-Package Arax.SimpleResult The library offers a straightforward approach to managing success and failure scenarios, making your code more readable, maintainable, and less prone to errors. SimpleResult is a lightweight library that provides a convenient way to handle the results of operations in your. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |