20 changed files with 192 additions and 187 deletions
@ -1,75 +0,0 @@ |
|||
using System; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace OpenIddict.Abstractions |
|||
{ |
|||
/// <summary>
|
|||
/// Represents an OpenIddict exception.
|
|||
/// </summary>
|
|||
public class OpenIddictException : Exception |
|||
{ |
|||
/// <summary>
|
|||
/// Creates a new <see cref="OpenIddictException"/>.
|
|||
/// </summary>
|
|||
/// <param name="reason">The reason of the exception.</param>
|
|||
/// <param name="message">The exception message.</param>
|
|||
public OpenIddictException(string reason, string message) |
|||
: base(message) |
|||
{ |
|||
Reason = reason; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="OpenIddictException"/>.
|
|||
/// </summary>
|
|||
/// <param name="reason">The reason of the exception.</param>
|
|||
/// <param name="message">The exception message.</param>
|
|||
/// <param name="innerException">The inner exception.</param>
|
|||
public OpenIddictException(string reason, string message, Exception innerException) |
|||
: base(message, innerException) |
|||
{ |
|||
Reason = reason; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="OpenIddictException"/>.
|
|||
/// </summary>
|
|||
/// <param name="info">
|
|||
/// The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.
|
|||
/// </param>
|
|||
/// <param name="context">
|
|||
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
|
|||
/// </param>
|
|||
protected OpenIddictException(SerializationInfo info, StreamingContext context) |
|||
: base(info, context) |
|||
{ |
|||
Reason = info.GetString(nameof(Reason)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the reason that caused the exception to be thrown.
|
|||
/// </summary>
|
|||
public string Reason { get; } |
|||
|
|||
/// <summary>
|
|||
/// Serializes the members of this class.
|
|||
/// </summary>
|
|||
/// <param name="info">
|
|||
/// The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.
|
|||
/// </param>
|
|||
/// <param name="context">
|
|||
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
|
|||
/// </param>
|
|||
public override void GetObjectData(SerializationInfo info, StreamingContext context) |
|||
{ |
|||
if (info == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(info)); |
|||
} |
|||
|
|||
info.AddValue(nameof(Reason), Reason); |
|||
|
|||
base.GetObjectData(info, context); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
using System; |
|||
using System.Collections.Immutable; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace OpenIddict.Abstractions |
|||
{ |
|||
/// <summary>
|
|||
/// Exposes common exceptions thrown by OpenIddict.
|
|||
/// </summary>
|
|||
public static class OpenIddictExceptions |
|||
{ |
|||
/// <summary>
|
|||
/// Represents an OpenIddict concurrency exception.
|
|||
/// </summary>
|
|||
public class ConcurrencyException : Exception |
|||
{ |
|||
/// <summary>
|
|||
/// Creates a new <see cref="ConcurrencyException"/>.
|
|||
/// </summary>
|
|||
/// <param name="message">The exception message.</param>
|
|||
public ConcurrencyException(string message) |
|||
: this(message, exception: null) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="ConcurrencyException"/>.
|
|||
/// </summary>
|
|||
/// <param name="message">The exception message.</param>
|
|||
/// <param name="exception">The inner exception.</param>
|
|||
public ConcurrencyException(string message, Exception exception) |
|||
: base(message, exception) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Represents an OpenIddict validation exception.
|
|||
/// </summary>
|
|||
public class ValidationException : Exception |
|||
{ |
|||
/// <summary>
|
|||
/// Creates a new <see cref="ValidationException"/>.
|
|||
/// </summary>
|
|||
/// <param name="message">The exception message.</param>
|
|||
public ValidationException(string message) |
|||
: this(message, ImmutableArray.Create<ValidationResult>()) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="ValidationException"/>.
|
|||
/// </summary>
|
|||
/// <param name="message">The exception message.</param>
|
|||
/// <param name="results">The validation results.</param>
|
|||
public ValidationException(string message, ImmutableArray<ValidationResult> results) |
|||
: this(message, results, exception: null) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="ValidationException"/>.
|
|||
/// </summary>
|
|||
/// <param name="message">The exception message.</param>
|
|||
/// <param name="results">The validation results.</param>
|
|||
/// <param name="exception">The inner exception.</param>
|
|||
public ValidationException(string message, ImmutableArray<ValidationResult> results, Exception exception) |
|||
: base(message, exception) |
|||
{ |
|||
Results = results; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the validation results associated with this exception.
|
|||
/// </summary>
|
|||
public ImmutableArray<ValidationResult> Results { get; } |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue