//------------------------------------------------------------------------------
//
// Copyright (c) 2002-2006 CodeSmith Tools, LLC.  All rights reserved.
// 
// The terms of use for this software are contained in the file
// named sourcelicense.txt, which can be found in the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
// 
// You must not remove this notice, or any other, from this software.
//
//------------------------------------------------------------------------------

using System;

namespace CodeSmith.BaseTemplates
{
	/// <summary>
	/// An error that occured during a script execution.
	/// </summary>
	public class ScriptError
	{
		private byte _errorClass;
		private int _lineNumber;
		private string _message;
		private int _number;
		private string _procedure;
		private byte _state;
		
		public ScriptError(int infoNumber, byte errorState, byte errorClass, string errorMessage, string procedure, int lineNumber)
		{
			_errorClass = errorClass;
			_lineNumber = lineNumber;
			_message = errorMessage;
			_number = infoNumber;
			_procedure = procedure;
			_state = errorState;
		}
		
		public override string ToString()
		{
			return String.Format("Server: Msg {0}, Level {1}, State {2}, Line {3}\r\n{4}\r\n", this.Number, this.Class, this.State, this.LineNumber, this.Message);
		}
		
		public byte Class
		{
			get {return _errorClass;}
		}
		
		public int LineNumber
		{
			get {return _lineNumber;}
		}
		
		public string Message
		{
			get {return _message;}
		}
		
		public int Number
		{
			get {return _number;}
		}
		
		public string Procedure
		{
			get {return _procedure;}
		}
		
		public byte State
		{
			get {return _state;}
		}
	}
}
