ficdown/Ficdown.Parser/Model/Parser/FicdownException.cs

30 lines
897 B
C#
Raw Normal View History

namespace Ficdown.Parser.Model.Parser
{
using System;
public class FicdownException : Exception
{
2015-07-24 00:56:53 -05:00
public string BlockName { get; private set; }
public int? LineNumber { get; private set; }
public FicdownException(string blockName, int? lineNumber, string message) : base(message)
{
2015-07-24 00:56:53 -05:00
BlockName = blockName;
LineNumber = lineNumber;
}
2015-07-24 00:56:53 -05:00
public FicdownException(string message) : base(message) { }
public override string ToString()
{
2015-07-24 00:56:53 -05:00
return !string.IsNullOrEmpty(BlockName)
? string.Format("Error in block \"{0}\" (Line {1}): {2}",
2015-07-24 00:56:53 -05:00
BlockName,
LineNumber.HasValue
? LineNumber.ToString()
: "unknown", Message)
: string.Format("Error: {0}", Message);
}
}
}