|
using System;
using System.Runtime.Serialization;
namespace TypedUnits
{
/// <summary>
/// Exception thrown when a unit conversion failed, i.e. because you are converting
/// amounts from one unit into another non-compatible unit.
/// </summary>
[Serializable]
public class UnitConversionException : InvalidOperationException
{
public UnitConversionException() : base() { }
public UnitConversionException(string message) : base(message) { }
public UnitConversionException(Unit fromUnit, Unit toUnit) : this(String.Format("Failed to convert from unit '{0}' to unit '{1}'. Units are not compatible and no conversions are defined.", fromUnit.Name, toUnit.Name)) { }
protected UnitConversionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
}
/// <summary>
/// Exception thrown whenever an exception is referenced by name, but no
/// unit with the given name is known (registered to the UnitManager).
/// </summary>
[Serializable]
public class UnknownUnitException : ApplicationException
{
public UnknownUnitException() : base() { }
public UnknownUnitException(string message) : base(message) { }
protected UnknownUnitException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.