Exemple #1
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ComputeApiException"/> class.
 /// </summary>
 /// <param name="error">
 /// The error.
 /// </param>
 /// <param name="uri">
 /// The uri.
 /// </param>
 /// <param name="messageOrFormat">
 /// The message or format.
 /// </param>
 /// <param name="formatArguments">
 /// The format arguments.
 /// </param>
 public ComputeApiException(
     ComputeApiError error,
     Uri uri,
     string messageOrFormat,
     params object[] formatArguments)
     : base(messageOrFormat, formatArguments)
 {
     Error = error;
     Uri   = uri;
 }
        /// <summary>
        ///		Deserialisation constructor for <see cref="ComputeApiException"/>.
        /// </summary>
        /// <param name="info">
        ///		A <see cref="SerializationInfo"/> serialisation data store that holds the serialized exception data.
        /// </param>
        /// <param name="context">
        ///		A <see cref="StreamingContext"/> value that indicates the source of the serialised data.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		The <paramref name="info"/> parameter is null.
        /// </exception>
        /// <exception cref="SerializationException">
        ///		The class name is <c>null</c> or <see cref="Exception.HResult"/> is zero (0).
        /// </exception>
        protected ComputeApiException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            _error            = (ComputeApiError)info.GetValue("_error", typeof(ComputeApiError));
            _additionalDetail = info.GetString("_additionalDetail");
        }
        /// <summary>
        ///		Create a new <see cref="ComputeApiException"/>.
        /// </summary>
        /// <param name="error">
        ///		The reason that the exception is being raised.
        /// </param>
        /// <param name="additionalDetail">
        ///		Additional error detail (if any) provided by the CaaS API.
        /// </param>
        /// <param name="messageOrFormat">
        ///		The exception message or message format.
        /// </param>
        /// <param name="innerException">
        ///		A previous exception that caused the current exception to be raised.
        /// </param>
        /// <param name="formatArguments">
        ///		Optional message format arguments.
        /// </param>
        public ComputeApiException(ComputeApiError error, string additionalDetail, string messageOrFormat, Exception innerException, params object[] formatArguments)
            : base(messageOrFormat, innerException, formatArguments)
        {
            Debug.Assert(error != ComputeApiError.Unknown, "Reason.Unknown should not be used here.");
            Debug.Assert(!String.IsNullOrWhiteSpace(messageOrFormat), "Exception message should not be empty.");

            _error            = error;
            _additionalDetail =
                !String.IsNullOrWhiteSpace(additionalDetail) ?
                additionalDetail
                                        :
                DefaultAdditionalErrorDetailMessage;
        }
		/// <summary>
		/// Initialises a new instance of the <see cref="ComputeApiException"/> class. 
		/// Create a new <see cref="ComputeApiException"/>.
		/// </summary>
		/// <param name="error">
		/// The reason that the exception is being raised.
		/// </param>
		/// <param name="additionalDetail">
		/// Additional error detail (if any) provided by the CaaS API.
		/// </param>
		/// <param name="messageOrFormat">
		/// The exception message or message format.
		/// </param>
		/// <param name="formatArguments">
		/// Optional message format arguments.
		/// </param>
		public ComputeApiException(ComputeApiError error, string additionalDetail, string messageOrFormat, 
			params object[] formatArguments)
			: base(messageOrFormat, formatArguments)
		{
			Debug.Assert(error != ComputeApiError.Unknown, "Reason.Unknown should not be used here.");
			Debug.Assert(!string.IsNullOrWhiteSpace(messageOrFormat), "Exception message should not be empty.");

			_error = error;

			_additionalDetail =
				!string.IsNullOrWhiteSpace(additionalDetail)
					? additionalDetail
					: DefaultAdditionalErrorDetailMessage;
		}
		/// <summary>
		/// Initialises a new instance of the <see cref="ComputeApiException"/> class. 
		/// Deserialisation constructor for <see cref="ComputeApiException"/>.
		/// </summary>
		/// <param name="info">
		/// A <see cref="SerializationInfo"/> serialisation data store that holds the serialized exception data.
		/// </param>
		/// <param name="context">
		/// A <see cref="StreamingContext"/> value that indicates the source of the serialised data.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// The <paramref name="info"/> parameter is null.
		/// </exception>
		/// <exception cref="SerializationException">
		/// The class name is <c>null</c> or <see cref="Exception.HResult"/> is zero (0).
		/// </exception>
		protected ComputeApiException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
			if (info == null)
				throw new ArgumentNullException("info");

			_error = (ComputeApiError) info.GetValue("_error", typeof (ComputeApiError));
			_additionalDetail = info.GetString("_additionalDetail");
		}
		/// <summary>
		/// Initialises a new instance of the <see cref="ComputeApiException"/> class.
		/// </summary>
		/// <param name="error">
		/// The error.
		/// </param>
		/// <param name="messageOrFormat">
		/// The message or format.
		/// </param>
		/// <param name="formatArguments">
		/// The format arguments.
		/// </param>
		public ComputeApiException(ComputeApiError error, string messageOrFormat, params object[] formatArguments)
			: base(messageOrFormat, formatArguments)
		{
			Error = error;
		}
 /// <summary>
 /// Initialises a new instance of the <see cref="DD.CBU.Compute.Api.Client.Exceptions.BadRequestException"/> class.
 /// </summary>
 /// <param name="error">Error Type</param>
 /// <param name="caasOperationResponse">
 /// The caa operation response.
 /// </param>
 /// <param name="uri">
 /// The uri.
 /// </param>
 public ComputeApiWithStatusException(ComputeApiError error, ResponseType caasOperationResponse, Uri uri)
     : base(error, uri, String.Empty)
 {
     CaaSOperationResponse = caasOperationResponse;
 }
 /// <summary>
 /// Initialises a new instance of the <see cref="DD.CBU.Compute.Api.Client.Exceptions.ComputeApiWithStatusException"/> class.
 /// </summary>
 /// <param name="error">Error Type, for older clients</param>
 /// <param name="caasOperationStatus">
 /// The caa operation status.
 /// </param>
 /// <param name="uri">
 /// The uri.
 /// </param>
 public ComputeApiWithStatusException(ComputeApiError error, Status caasOperationStatus, Uri uri)
     : base(error, uri, String.Empty)
 {
     CaaSOperationStatus = caasOperationStatus;
 }
 /// <summary>
 /// Initialises a new instance of the <see cref="DD.CBU.Compute.Api.Client.Exceptions.ComputeApiWithStatusException"/> class.
 /// </summary>
 /// <param name="error">Error Type, for older clients</param>
 /// <param name="caasRawResponse">
 /// The caa operation status.
 /// </param>
 /// <param name="uri">
 /// The uri.
 /// </param>
 public ComputeApiWithStatusException(ComputeApiError error, string caasRawResponse, Uri uri)
     : base(error, uri, String.Empty)
 {
     CaasRawResponse = caasRawResponse;
 }