// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Perspex.Data
{
///
/// Represents a recoverable binding error.
///
///
/// When produced by a binding source observable, informs the binding system that an error
/// occurred. It can also provide an optional fallback value to be pushed to the binding
/// target.
///
/// Instead of using , one could simply not push a value (in the
/// case of a no fallback value) or push a fallback value, but BindingError also causes an
/// error to be logged with the correct binding target.
///
public class BindingError
{
///
/// Initializes a new instance of the class.
///
/// An exception describing the binding error.
public BindingError(Exception exception)
{
Exception = exception;
}
///
/// Initializes a new instance of the class.
///
/// An exception describing the binding error.
/// The fallback value.
public BindingError(Exception exception, object fallbackValue)
{
Exception = exception;
FallbackValue = fallbackValue;
UseFallbackValue = true;
}
///
/// Gets the exception describing the binding error.
///
public Exception Exception { get; }
///
/// Get the fallback value.
///
public object FallbackValue { get; }
///
/// Get a value indicating whether the fallback value should be pushed to the binding
/// target.
///
public bool UseFallbackValue { get; }
}
}