Skip to content

Commit 9e0f9fb

Browse files
committed
Logging an error message when a function has an invalid WebHook configuration.
1 parent f54bfb6 commit 9e0f9fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/WebJobs.Script.WebHost/WebHooks/WebHookReceiverManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Globalization;
67
using System.Linq;
78
using System.Net.Http;
89
using System.Threading.Tasks;
@@ -12,6 +13,7 @@
1213
using Autofac.Integration.WebApi;
1314
using Microsoft.AspNet.WebHooks;
1415
using Microsoft.AspNet.WebHooks.Config;
16+
using Microsoft.Azure.WebJobs.Host;
1517
using Microsoft.Azure.WebJobs.Script.Description;
1618

1719
namespace WebJobs.Script.WebHost.WebHooks
@@ -54,7 +56,10 @@ public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor fun
5456
IWebHookReceiver receiver = null;
5557
if (string.IsNullOrEmpty(webHookReceiver) || !_receiverLookup.TryGetValue(webHookReceiver, out receiver))
5658
{
57-
// If the function is a not a correctly configured WebHook return 500
59+
// The function is not correctly configured. Log an error and return 500
60+
string configurationError = string.Format(CultureInfo.InvariantCulture, "Invalid WebHook configuration. Unable to find a receiver for WebHook type '{0}'", webHookReceiver);
61+
function.Invoker.OnError(new FunctionInvocationException(configurationError));
62+
5863
return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
5964
}
6065

0 commit comments

Comments
 (0)