Skip to content

Commit

Permalink
Added response validation exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimms committed Jul 28, 2023
1 parent 6576227 commit 4cd4fc5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Task SetValueAsync(object result, CancellationToken cancellationToken)
{
if (result == null)
{
throw new ArgumentNullException("AuthenticationEventResponseHandler", AuthenticationEventResource.Ex_Invalid_Return);
throw new ResponseValidationException(AuthenticationEventResource.Ex_Invalid_Return);
}

if (result is AuthenticationEventResponse action)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;

namespace Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents
{
/// <summary>
/// Exception class for response validations
/// </summary>
public class ResponseValidationException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="ResponseValidationException"/> class.
/// </summary>
/// <param name="message"></param>
public ResponseValidationException(string message)
: base(message) { }

/// <summary>
/// Initializes a new instance of the <see cref="ResponseValidationException"/> class.
/// </summary>
/// <param name="message"></param>
/// <param name="innerException"></param>
public ResponseValidationException(string message, Exception innerException)
: base(message, innerException) { }
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"errors": [ "Return type is invalid, please return either an AuthEventResponse, HttpResponse, HttpResponseMessage or string in your function return. (Parameter 'AuthenticationEventResponseHandler')" ]
"errors": [ "Return type is invalid, please return either an AuthEventResponse, HttpResponse, HttpResponseMessage or string in your function return." ]
}

0 comments on commit 4cd4fc5

Please sign in to comment.