public CommandException Translate(DbException exception, IDictionary <string, object> options = null)
        {
            Condition.Requires(exception, nameof(exception)).IsNotNull();
            Condition.Requires(options, nameof(options))
            .IsNotNull()
            .Evaluate(options.ContainsKey("Command"));
            var     command         = (ICommand)options["Command"];
            dynamic oracleException = exception;

            foreach (dynamic error in oracleException.Errors)
            {
                if (OracleErrorHelper.IsUnavailableError(error))
                {
                    return(new CommandUnavailableException(command, exception));
                }

                if (OracleErrorHelper.IsUnauthorizedError(error))
                {
                    return(new CommandUnauthorizedException(command, exception));
                }

                if (OracleErrorHelper.IsTimeoutError(error))
                {
                    return(new CommandTimeoutException(command, exception));
                }
            }
            return(new CommandException(isTransient: false, command, exception));
        }
        public RepositoryException Translate(DbException exception, IDictionary <string, object> options = null)
        {
            Condition.Requires(exception, nameof(exception)).IsNotNull();
            Condition.Requires(options, nameof(options))
            .IsNotNull()
            .Evaluate(options.ContainsKey("EntityType"));
            var     entityType      = (Type)options["EntityType"];
            var     outerException  = options.ContainsKey("OuterException") ? (Exception)options["OuterException"] : exception;
            dynamic oracleException = exception;

            foreach (dynamic error in oracleException.Errors)
            {
                if (OracleErrorHelper.IsUnavailableError(error))
                {
                    return(new RepositoryUnavailableException(entityType, outerException));
                }

                if (OracleErrorHelper.IsUnauthorizedError(error))
                {
                    return(new RepositoryUnauthorizedException(entityType, outerException));
                }

                if (OracleErrorHelper.IsTimeoutError(error))
                {
                    return(new RepositoryTimeoutException(entityType, outerException));
                }
            }
            return(new RepositoryException(isTransient: false, entityType, outerException));
        }
Exemple #3
0
        public QueryException Translate(DbException exception, IDictionary <string, object> options = null)
        {
            Condition.Requires(exception, nameof(exception)).IsNotNull();
            Condition.Requires(options, nameof(options))
            .IsNotNull()
            .Evaluate(options.ContainsKey("Query"));
            var     query           = (IQuery)options["Query"];
            dynamic oracleException = exception;

            foreach (dynamic error in oracleException.Errors)
            {
                if (OracleErrorHelper.IsUnavailableError(error))
                {
                    return(new QueryUnavailableException(query, exception));
                }

                if (OracleErrorHelper.IsUnauthorizedError(error))
                {
                    return(new QueryUnauthorizedException(query, exception));
                }

                if (OracleErrorHelper.IsTimeoutError(error))
                {
                    return(new QueryTimeoutException(query, exception));
                }
            }
            return(new QueryException(isTransient: false, query, exception));
        }