Search Results for

    Show / Hide Table of Contents

    Class Try<T>

    Represents either success or failure of some operation

    Inheritance
    object
    Try<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Util
    Assembly: Akka.dll
    Syntax
    public class Try<T>
    Type Parameters
    Name Description
    T

    Success type

    Constructors

    | Edit this page View Source

    Try(Exception)

    Creates Try<T> with failure

    Declaration
    public Try(Exception failure)
    Parameters
    Type Name Description
    Exception failure
    | Edit this page View Source

    Try(T)

    Creates Try<T> with success result

    Declaration
    public Try(T success)
    Parameters
    Type Name Description
    T success

    Properties

    | Edit this page View Source

    Failure

    If set, contains failure description

    Declaration
    public Option<Exception> Failure { get; }
    Property Value
    Type Description
    Option<Exception>
    | Edit this page View Source

    IsSuccess

    Shows if this is Success

    Declaration
    public bool IsSuccess { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Success

    If set, contains successfull execution result

    Declaration
    public Option<T> Success { get; }
    Property Value
    Type Description
    Option<T>

    Methods

    | Edit this page View Source

    From(Func<T>)

    Gets Try<T> result from function execution

    Declaration
    public static Try<T> From(Func<T> func)
    Parameters
    Type Name Description
    Func<T> func
    Returns
    Type Description
    Try<T>
    | Edit this page View Source

    Get()

    Returns the value from this Success or throws the exception if this is a Failure.

    Declaration
    public T Get()
    Returns
    Type Description
    T
    | Edit this page View Source

    GetOrElse(Func<T>)

    Returns this Try if it's a Success or tries execute given fallback if this is a Failure.

    Declaration
    public Try<T> GetOrElse(Func<T> fallback)
    Parameters
    Type Name Description
    Func<T> fallback
    Returns
    Type Description
    Try<T>
    | Edit this page View Source

    OrElse(Try<T>)

    Returns this Try if it's a Success or the given default argument if this is a Failure.

    Declaration
    public Try<T> OrElse(Try<T> @default)
    Parameters
    Type Name Description
    Try<T> default
    Returns
    Type Description
    Try<T>
    | Edit this page View Source

    Recover(Action<Exception>)

    Applies the given function f if this is a Failure, otherwise returns this if this is a Success.

    Declaration
    public Try<T> Recover(Action<Exception> failureHandler)
    Parameters
    Type Name Description
    Action<Exception> failureHandler
    Returns
    Type Description
    Try<T>
    | Edit this page View Source

    RecoverWith(Func<Exception, Try<T>>)

    Applies the given function f if this is a Failure, otherwise returns this if this is a Success.

    Declaration
    public Try<T> RecoverWith(Func<Exception, Try<T>> failureHandler)
    Parameters
    Type Name Description
    Func<Exception, Try<T>> failureHandler
    Returns
    Type Description
    Try<T>

    Operators

    | Edit this page View Source

    implicit operator Try<T>(T)

    Declaration
    public static implicit operator Try<T>(T value)
    Parameters
    Type Name Description
    T value
    Returns
    Type Description
    Try<T>

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET