20 changed files with 191 additions and 154 deletions
@ -1,38 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
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>
|
|
||||
/// Gets the reason that caused the exception to be thrown.
|
|
||||
/// </summary>
|
|
||||
public string Reason { get; } |
|
||||
} |
|
||||
} |
|
||||
@ -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