// ******************************************************************************************
// **                                                                                       **
// **      RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION                 **
// **      PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS         **
// **      AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT.DISCLOSURE TO                **
// **      UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO          **
// **      RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS              **
// **      CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS         **
// **      OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON        **
// **      COMPANY.                                                                         **
// **                                                                                       **
// **      THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.               **
// **      GOVERNMENT.                                                                      **
// **                                                                                       **
// **      UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.                                   **
// **                                                                                       **
// **      WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE         **
// **      EXPORT OR DISCLOSURE TO NON-U.S.PERSONS, WHEREVER LOCATED, IS RESTRICTED         **
// **      BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R.SECTION        **
// **      120-130) OR THE EXPORT ADMINISTRATION REGULATIONS(EAR) (15 C.F.R.SECTION         **
// **      730-774). THIS DOCUMENT CANNOT BE EXPORTED(E.G., PROVIDED TO A SUPPLIER          **
// **      OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S.PERSON, WHEREVER         **
// **      LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS         **
// **      BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S.GOVERNMENT         **
// **      APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL          **
// **      PENALTIES.                                                                       **
// **                                                                                       **
// **      CAPITAL EQUIPMENT/SOFTWARE: THIS TECHNICAL DATA WAS DEVELOPED OR ACQUIRED        **
// **      EXCLUSIVELY AT CONTRACTOR EXPENSE AND IS INTENDED FOR USE ON MULTIPLE            **
// **      PROJECTS/PROGRAMS.                                                               **
// **                                                                                       **
// *******************************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Raytheon.Instruments
{
    /// <summary>
    /// InstrumentException - an exception that can be thrown by all instruments
    ///                       while processing any instruction
    /// <remarks>can be used as a base class</remarks>
    /// </summary>
    [DataContract]
    public class InstrumentException : Exception
    {
        [DataMember]
        private string _message = string.Empty;

        [DataMember]
        private int _errorCode = 0;
        
        /// <summary>
        /// Message - readable information associated with the exception
        /// </summary>
        public override string Message
        {
            get
            {
                return _message;
            }
        }

        /// <summary>
        /// ErrorCode - code associated with error involved with this exception
        /// </summary>
        public int ErrorCode
        {
            get { return _errorCode; }
            set { _errorCode = value; }
        }

        /// <summary>
        /// InstrumentException - default constructor
        /// </summary>
        public InstrumentException()
            : base()
        {
        }

        /// <summary>
        /// InstrumentException - constructor with a message as parameter
        /// </summary>
        /// <param name="message">message about the exception</param>
        public InstrumentException(string message)
            : base()
        {
            _message = message;
        }

        /// <summary>
        /// InstrumentException - constructor that takes an error code
        /// </summary>
        /// <param name="errorCode">the error code</param>
        public InstrumentException(int errorCode)
            : base()
        {
            _errorCode = errorCode;
        }

        /// <summary>
        /// InstrumentException - constructor that takes an error code and message
        /// </summary>
        /// <param name="errorCode">the error code</param>
        /// <param name="message">the message</param>
        public InstrumentException(int errorCode, string message)
            : base()
        {
            _message = message;
            _errorCode = errorCode;
        }

        /// <summary>
        /// InstrumentException - constructor that takes an error message and inner exception
        /// </summary>
        /// <param name="message">the message</param>
        /// <param name="innerException">an inner exception</param>
        public InstrumentException(string message, Exception innerException)
            : base(message, innerException)
        {
            _message = message;
        }

        /// <summary>
        /// InstrumentException - protected constructor
        /// </summary>
        /// <param name="info">serialization info</param>
        /// <param name="context">context</param>
        protected InstrumentException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        /// <summary>
        /// GetObjectData - override for serialization
        /// </summary>
        /// <param name="info">how to serialize</param>
        /// <param name="context">context</param>
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }
    }
}
