Exemple #1
0
        /// <summary>
        ///     This method *has* to convert whatever NHibernate exception to a valid PPWCode exception
        ///     Some hibernate exceptions might be semantic, some might be errors.
        ///     This may depend on the actual product.
        ///     This method translates semantic exceptions in PPWCode.Util.Exception.SemanticException and throws them
        ///     and all other exceptions in PPWCode.Util.Exception.Error and throws them.
        /// </summary>
        /// <param name="exception">The hibernate exception we are triaging.</param>
        /// <param name="message">This message will be used in the logging in the case aException = Error.</param>
        /// <returns>An exception that is a sub class either from <see cref="SemanticException" /> or from <see cref="Error" />.</returns>
        protected virtual Exception TriageException(Exception exception, string message)
        {
            Contract.Requires(exception != null);
            Contract.Requires(!string.IsNullOrEmpty(message));

            Exception result;

            Logger.Debug(message, exception);
            GenericADOException genericAdoException = exception as GenericADOException;

            if (genericAdoException != null)
            {
                RepositorySqlException repositorySqlException =
                    new RepositorySqlException(message, genericAdoException.InnerException)
                {
                    SqlString = genericAdoException.SqlString,
                };
                SqlException sqlException = genericAdoException.InnerException as SqlException;
                if (sqlException != null)
                {
                    repositorySqlException.Constraint = sqlException.GetConstraint();
                }

                result = repositorySqlException;
            }
            else
            {
                result = new ExternalError(message, exception);
            }

            throw result;
        }
Exemple #2
0
 protected virtual HttpStatusCode DetermineHttpStatusCode([NotNull] RepositorySqlException rse)
 => HttpStatusCode.InternalServerError;