123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Data.Common;
- namespace EasyDevCore.Database
- {
- /// <summary>
- ///
- /// </summary>
- public static class ExceptionBuilder
- {
- /// <summary>
- /// Transactions the error.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception TransactionError(string message)
- {
- return new Exception(message);
- }
- /// <summary>
- /// Nots the supported exception.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception NotSupportedException(string message = null)
- {
- return new NotSupportedException(message);
- }
- /// <summary>
- /// Arguments the null.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception ArgumentNull(string message = null)
- {
- return new ArgumentNullException(message);
- }
- /// <summary>
- /// Arguments the out of range.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception ArgumentOutOfRange(string message = null)
- {
- return new ArgumentOutOfRangeException(message);
- }
- /// <summary>
- /// Invalids the length of the offset.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception InvalidOffsetLength(string message = null)
- {
- return new ArgumentException(message);
- }
- /// <summary>
- /// Columns the out of range.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <returns></returns>
- public static Exception ColumnOutOfRange(int index)
- {
- return new IndexOutOfRangeException();
- }
- /// <summary>
- /// Columns the not in entity.
- /// </summary>
- /// <param name="columnName">Name of the column.</param>
- /// <param name="entityName">Name of the entity.</param>
- /// <returns></returns>
- public static Exception ColumnNotInEntity(string columnName, string entityName)
- {
- return new ArgumentException();
- }
- /// <summary>
- /// Columns the out of range.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="entityName">Name of the entity.</param>
- /// <returns></returns>
- public static Exception ColumnOutOfRange(int index, string entityName)
- {
- return new ArgumentException();
- }
- /// <summary>
- /// Arguments the type not support.
- /// </summary>
- /// <param name="typeName">Name of the type.</param>
- /// <returns></returns>
- public static Exception ArgumentTypeNotSupport(string typeName)
- {
- return new ArgumentException(typeName);
- }
- /// <summary>
- /// Nots the implemented exception.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception NotImplementedException(string message = null)
- {
- return new NotImplementedException(message);
- }
- /// <summary>
- /// Invalids the cast exception.
- /// </summary>
- /// <param name="fromType">From type.</param>
- /// <param name="toType">To type.</param>
- /// <returns></returns>
- public static Exception InvalidCastException(Type fromType, Type toType)
- {
- return new InvalidCastException($"Type: {fromType.Name} not cast to {toType.Name}");
- }
- /// <summary>
- /// Concurrencies the exception.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <returns></returns>
- public static Exception ConcurrencyException(string message)
- {
- return new ConcurrencyException(message);
- }
- }
- }
|