/// <summary>
        /// This creates a default Unhandled error and returns the result from the process error function.
        /// </summary>
        /// <param name="exception">Exception.</param>
        /// <returns>Object Result.</returns>
        public static ApiObjectResult UnhandledError(Exception exception = null)
        {
            InternalRestError internalRestError = new InternalRestError(
                ErrorConstants.UnhandledErrorCode,
                ErrorConstants.UnhandledErrorMessage,
                exception);

            return(ProcessError(internalRestError));
        }
        /// <summary>
        /// This will process an Error, and create an appropriate response code.
        /// </summary>
        /// <param name="internalRestError">Error to process.</param>
        /// <returns>Object Result.</returns>
        public static ApiObjectResult ProcessError(InternalRestError internalRestError)
        {
            switch (internalRestError.ErrorCode)
            {
            case ErrorConstants.ResourceConflictErrorCode:
            case ErrorConstants.VersionAlreadyExistsErrorCode:
            case ErrorConstants.InstallerAlreadyExistsErrorCode:
            case ErrorConstants.LocaleAlreadyExistsErrorCode:
                return(CreateObjectResult(internalRestError, (int)HttpStatusCode.Conflict));

            case ErrorConstants.ResourceNotFoundErrorCode:
            case ErrorConstants.VersionsIsNullErrorCode:
            case ErrorConstants.VersionDoesNotExistErrorCode:
            case ErrorConstants.InstallerIsNullErrorCode:
            case ErrorConstants.InstallerDoesNotExistErrorCode:
            case ErrorConstants.LocaleIsNullErrorCode:
            case ErrorConstants.LocaleDoesNotExistErrorCode:
                return(CreateObjectResult(internalRestError, (int)HttpStatusCode.NotFound));

            case ErrorConstants.PreconditionFailedErrorCode:
                return(CreateObjectResult(internalRestError, (int)HttpStatusCode.PreconditionFailed));

            case ErrorConstants.PackageDoesNotMatchErrorCode:
            case ErrorConstants.VersionDoesNotMatchErrorCode:
            case ErrorConstants.InstallerDoesNotMatchErrorCode:
            case ErrorConstants.LocaleDoesNotMatchErrorCode:
            case ErrorConstants.ValidationFailureErrorCode:
            case ErrorConstants.HeadersAreNullErrorCode:
            case ErrorConstants.ServerVersionNotSupportedErrorCode:
            case ErrorConstants.ToManyContinuationTokensErrorCode:
                return(CreateObjectResult(internalRestError, (int)HttpStatusCode.BadRequest));

            case ErrorConstants.HttpRequestExceptionErrorCode:
            case ErrorConstants.UnhandledErrorCode:
            default:
                return(CreateObjectResult(internalRestError, (int)HttpStatusCode.InternalServerError));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultException"/> class.
 /// </summary>
 /// <param name="message">Exception message.</param>
 /// <param name="inner">Inner exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public DefaultException(string message, Exception inner, InternalRestError internalRestError)
     : base(message, inner)
 {
     this.InternalRestError = internalRestError;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultException"/> class.
 /// </summary>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public DefaultException(InternalRestError internalRestError)
     : base(internalRestError.ErrorMessage)
 {
     this.InternalRestError = internalRestError;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultException"/> class.
 /// </summary>
 /// <param name="exception">Exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public DefaultException(Exception exception, InternalRestError internalRestError)
     : base(exception.Message, exception.InnerException)
 {
     this.InternalRestError = internalRestError;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidArgumentException"/> class.
 /// </summary>
 /// <param name="exception">Exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public InvalidArgumentException(Exception exception, InternalRestError internalRestError)
     : base(exception, internalRestError)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidArgumentException"/> class.
 /// </summary>
 /// <param name="message">Exception message.</param>
 /// <param name="inner">Inner exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public InvalidArgumentException(string message, Exception inner, InternalRestError internalRestError)
     : base(message, inner, internalRestError)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidArgumentException"/> class.
 /// </summary>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public InvalidArgumentException(InternalRestError internalRestError)
     : base(internalRestError)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CosmosDatabaseException"/> class.
 /// </summary>
 /// <param name="exception">Exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public CosmosDatabaseException(Exception exception, InternalRestError internalRestError)
     : base(exception, internalRestError)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CosmosDatabaseException"/> class.
 /// </summary>
 /// <param name="message">Exception message.</param>
 /// <param name="inner">Inner exception.</param>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public CosmosDatabaseException(string message, Exception inner, InternalRestError internalRestError)
     : base(message, inner, internalRestError)
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CosmosDatabaseException"/> class.
 /// </summary>
 /// <param name="internalRestError">Internal Rest Error.</param>
 public CosmosDatabaseException(InternalRestError internalRestError)
     : base(internalRestError)
 {
 }