// Copyright 2009-2022 Josh Close
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
// https://github.com/JoshClose/CsvHelper
using CsvHelper.Configuration;
using System;
namespace CsvHelper.TypeConversion
{
///
/// Represents errors that occur while reading a CSV file.
///
[Serializable]
public class TypeConverterException : CsvHelperException
{
///
/// The text used in ConvertFromString.
///
public string Text { get; private set; }
///
/// The value used in ConvertToString.
///
public object Value { get; private set; }
///
/// The type converter.
///
public ITypeConverter TypeConverter { get; private set; }
///
/// The member map data used in ConvertFromString and ConvertToString.
///
public MemberMapData MemberMapData { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The type converter.
/// The member map data.
/// The text.
/// The reading context.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, string text, CsvContext context) : base(context)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Text = text;
}
///
/// Initializes a new instance of the class.
///
/// The type converter.
/// The member map data.
/// The value.
/// The writing context.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, object value, CsvContext context) : base(context)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Value = value;
}
///
/// Initializes a new instance of the class
/// with a specified error message.
///
/// The type converter.
/// The member map data.
/// The text.
/// The reading context.
/// The message that describes the error.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, string text, CsvContext context, string message) : base(context, message)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Text = text;
}
///
/// Initializes a new instance of the class
/// with a specified error message.
///
/// The type converter.
/// The member map data.
/// The value.
/// The writing context.
/// The message that describes the error.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, object value, CsvContext context, string message) : base(context, message)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Value = value;
}
///
/// Initializes a new instance of the class
/// with a specified error message and a reference to the inner exception that
/// is the cause of this exception.
///
/// The type converter.
/// The member map data.
/// The text.
/// The reading context.
/// The error message that explains the reason for the exception.
/// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, string text, CsvContext context, string message, Exception innerException) : base(context, message, innerException)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Text = text;
}
///
/// Initializes a new instance of the class
/// with a specified error message and a reference to the inner exception that
/// is the cause of this exception.
///
/// The type converter.
/// The member map data.
/// The value.
/// The writing context.
/// The error message that explains the reason for the exception.
/// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, object value, CsvContext context, string message, Exception innerException) : base(context, message, innerException)
{
TypeConverter = typeConverter;
MemberMapData = memberMapData;
Value = value;
}
}
}