init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
469
Sda.DataProvider/Exceptions.cs
Normal file
469
Sda.DataProvider/Exceptions.cs
Normal file
|
@ -0,0 +1,469 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SDA.DataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Hibakódok
|
||||
/// </summary>
|
||||
public enum SDADataProviderError
|
||||
{
|
||||
/// <summary>
|
||||
/// Ismeretlen hiba
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// Egyedi kulcs megsértése
|
||||
/// </summary>
|
||||
UniqueKeyViolation,
|
||||
|
||||
/// <summary>
|
||||
/// Idegen kulcs megsértése
|
||||
/// </summary>
|
||||
ForeignKeyViolation,
|
||||
|
||||
/// <summary>
|
||||
/// A tábla vagy nézet nem létezik
|
||||
/// </summary>
|
||||
TableOrViewNotExists,
|
||||
|
||||
/// <summary>
|
||||
/// Érvénytelen oszlopnév
|
||||
/// </summary>
|
||||
InvalidColumnName,
|
||||
|
||||
/// <summary>
|
||||
/// Null érték nem beszúrható
|
||||
/// </summary>
|
||||
CannotInsertNull,
|
||||
|
||||
/// <summary>
|
||||
/// Adatbázis-kapcsolati hiba
|
||||
/// </summary>
|
||||
CommunicationError,
|
||||
|
||||
/// <summary>
|
||||
/// Táblaterekkel, rendelkezésre álló hellyel kapcsolatos hiba
|
||||
/// </summary>
|
||||
TableSpaceError,
|
||||
|
||||
/// <summary>
|
||||
/// Deadlock történt
|
||||
/// </summary>
|
||||
DeadlockDetected,
|
||||
|
||||
/// <summary>
|
||||
/// Adatbázis művelet időtúllépés történt
|
||||
/// </summary>
|
||||
CommandTimeout
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adatbázis hibát jelző kivétel.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SDADataProviderException : Exception
|
||||
{
|
||||
const string DefaultMessage = "SQL error!";
|
||||
|
||||
const string DefaultCommand = "";
|
||||
|
||||
const int DefaultDatabaseNumber = -1;
|
||||
|
||||
readonly string _commandText = DefaultCommand;
|
||||
|
||||
/// <summary>
|
||||
/// Mező annak jelzésére, hogy a művelet végrehajtását célszerű-e
|
||||
/// újra megpróbálni, mielőtt a kivételt továbbdobjuk.
|
||||
/// </summary>
|
||||
internal readonly bool MustRetry = false;
|
||||
|
||||
/// <summary>
|
||||
/// Hibakód.
|
||||
/// </summary>
|
||||
public SDADataProviderError Error { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Az eredeti - adatbázisfüggő - hibakód.
|
||||
/// </summary>
|
||||
public int DatabaseSpecificNumber { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public SDADataProviderException()
|
||||
: base(DefaultMessage)
|
||||
{
|
||||
Error = SDADataProviderError.Unknown;
|
||||
DatabaseSpecificNumber = DefaultDatabaseNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public SDADataProviderException(string message)
|
||||
: base(message ?? DefaultMessage)
|
||||
{
|
||||
Error = SDADataProviderError.Unknown;
|
||||
DatabaseSpecificNumber = DefaultDatabaseNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public SDADataProviderException(string message, Exception innerException)
|
||||
: base(message ?? DefaultMessage, innerException)
|
||||
{
|
||||
Error = SDADataProviderError.Unknown;
|
||||
DatabaseSpecificNumber = DefaultDatabaseNumber;
|
||||
}
|
||||
|
||||
internal SDADataProviderException(Exception innerException)
|
||||
: this(innerException == null ? DefaultMessage : innerException.Message, innerException) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
protected SDADataProviderException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
Error = (SDADataProviderError)info.GetValue("Error", typeof(SDADataProviderError));
|
||||
DatabaseSpecificNumber = info.GetInt32("DatabaseSpecificNumber");
|
||||
MustRetry = info.GetBoolean("MustRetry");
|
||||
}
|
||||
|
||||
internal SDADataProviderException(Exception innerException, SDADataProviderError error, int number, bool mustRetry, string commandText)
|
||||
: this(innerException == null ? DefaultMessage : innerException.Message, innerException)
|
||||
{
|
||||
Error = error;
|
||||
DatabaseSpecificNumber = number;
|
||||
MustRetry = mustRetry;
|
||||
_commandText = commandText ?? DefaultCommand;
|
||||
}
|
||||
|
||||
internal SDADataProviderException(Exception innerException, SDADataProviderError error, string commandText)
|
||||
: this(innerException, error, DefaultDatabaseNumber, false, commandText) { }
|
||||
|
||||
internal SDADataProviderException(Exception innerException, SDADataProviderError error, int number, string commandText)
|
||||
: this(innerException, error, number, false, commandText) { }
|
||||
|
||||
internal SDADataProviderException(Exception innerException, SDADataProviderError error, int number, bool mustRetry)
|
||||
: this(innerException, error, number, mustRetry, DefaultCommand) { }
|
||||
|
||||
/// <summary>
|
||||
/// A kivétel üzenete.
|
||||
/// </summary>
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_commandText))
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
@"{0}: {1}
|
||||
{2}",
|
||||
DatabaseSpecificNumber,
|
||||
_commandText,
|
||||
base.Message);
|
||||
}
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
@"{0}
|
||||
{1}",
|
||||
DatabaseSpecificNumber,
|
||||
base.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sorosítás.
|
||||
/// </summary>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("Error", Error);
|
||||
info.AddValue("DatabaseSpecificNumber", DatabaseSpecificNumber);
|
||||
info.AddValue("MustRetry", MustRetry);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holtpont.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class DeadlockException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public DeadlockException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public DeadlockException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public DeadlockException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
DeadlockException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal DeadlockException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.DeadlockDetected, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adatbázis művelet időtúllépés.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class CommandTimeoutException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommandTimeoutException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommandTimeoutException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommandTimeoutException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
CommandTimeoutException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal CommandTimeoutException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.CommandTimeout, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Táblatér hiba.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class TableSpaceErrorException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableSpaceErrorException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableSpaceErrorException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableSpaceErrorException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
TableSpaceErrorException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal TableSpaceErrorException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.TableSpaceError, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Egyediség megsértése.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class UniqueKeyViolationException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public UniqueKeyViolationException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public UniqueKeyViolationException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public UniqueKeyViolationException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
UniqueKeyViolationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal UniqueKeyViolationException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.UniqueKeyViolation, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Idegen kulcs megsértése.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class ForeignKeyViolationException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public ForeignKeyViolationException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public ForeignKeyViolationException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public ForeignKeyViolationException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
ForeignKeyViolationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal ForeignKeyViolationException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.ForeignKeyViolation, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tábla vagy nézet nem létezik.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class TableOrViewNotExistsException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableOrViewNotExistsException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableOrViewNotExistsException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public TableOrViewNotExistsException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
TableOrViewNotExistsException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal TableOrViewNotExistsException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.TableOrViewNotExists, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oszlop nem létezik.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class InvalidColumnNameException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public InvalidColumnNameException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public InvalidColumnNameException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public InvalidColumnNameException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
InvalidColumnNameException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal InvalidColumnNameException(Exception innerException, int number, string commandText)
|
||||
: base(innerException, SDADataProviderError.InvalidColumnName, number, false, commandText) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kommunikációs hiba.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class CommunicationErrorException : SDADataProviderException
|
||||
{
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommunicationErrorException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommunicationErrorException(string message)
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
public CommunicationErrorException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Szabványos konstruktor.
|
||||
/// </summary>
|
||||
CommunicationErrorException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
internal CommunicationErrorException(Exception innerException, int number)
|
||||
: base(innerException, SDADataProviderError.CommunicationError, number, false) { }
|
||||
|
||||
internal CommunicationErrorException(Exception innerException, int number, bool mustRetry)
|
||||
: base(innerException, SDADataProviderError.CommunicationError, number, mustRetry) { }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue