Example #1
0
        /// <summary>
        /// Convert errorCode to ErrorType
        /// </summary>
        /// <returns>
        /// The error type
        /// </returns>
        /// <param name='errorCode'>
        /// Error code
        /// </param>
        internal static ErrorType ToErrorType(byte errorCode)
        {
            BrickError brickError = (BrickError)errorCode;

            if (Enum.IsDefined(typeof(BrickError), brickError))
            {
                return(ErrorType.Brick);
            }
            TunnelError serverError = (TunnelError)errorCode;

            if (Enum.IsDefined(typeof(TunnelError), serverError))
            {
                return(ErrorType.Tunnel);
            }
            ConnectionError connectionError = (ConnectionError)errorCode;

            if (Enum.IsDefined(typeof(ConnectionError), connectionError))
            {
                return(ErrorType.Connection);
            }

            if (errorCode != 0)
            {
                return(ErrorType.Brick);
            }
            return(ErrorType.NoError);
        }
Example #2
0
        private static string errorToString(TunnelError error)
        {
            string errorDescription = "";

            switch (error)
            {
            case TunnelError.UnsupportedCommand:
                errorDescription = "Tunnel does not support the command";
                break;

            case TunnelError.ErrorExecuting:
                errorDescription = "Tunnel failed to execute command";
                break;

            default:
                errorDescription = "Unknown tunnel error";
                break;
            }
            return(errorDescription);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="MonoBrick.TunnelException"/>
 /// </summary>
 /// <param name='error'>
 /// Tunnel error
 /// </param>
 /// <param name='inner'>
 /// Inner exception
 /// </param>
 public TunnelException(TunnelError error, Exception inner) : base(errorToString(error), inner, (byte)error)
 {
 }
		/// <summary>
		/// Initializes a new instance of <see cref="MonoBrick.TunnelException"/>
		/// </summary>
		/// <param name='error'>
		/// Tunnel error
		/// </param>
		/// <param name='inner'>
		/// Inner exception
		/// </param>
		public TunnelException(TunnelError error, Exception inner): base(errorToString(error), inner, (byte) error){}
   		private static string errorToString(TunnelError error){
			string errorDescription = "";
			switch(error){
				case TunnelError.UnsupportedCommand:
					errorDescription = "Tunnel does not support the command";
					break;
				case TunnelError.ErrorExecuting:
					errorDescription = "Tunnel failed to execute command";
					break;
				default:
	            	errorDescription = "Unknown tunnel error";
				    break;
			}
			return errorDescription;
		}