From 8af04b24ed79711c889678c0bff5d1e6df6e1c3f Mon Sep 17 00:00:00 2001 From: maurok Date: Fri, 19 May 2017 17:19:16 -0300 Subject: [PATCH] # Adding hint message only if clientexception contains 'access denied' (code is zero) --- .../Controllers/MessagesController.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CSharp/intelligence-ImageCaption/Controllers/MessagesController.cs b/CSharp/intelligence-ImageCaption/Controllers/MessagesController.cs index 532312c313..3d01ea5ae7 100644 --- a/CSharp/intelligence-ImageCaption/Controllers/MessagesController.cs +++ b/CSharp/intelligence-ImageCaption/Controllers/MessagesController.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using System.Web.Http; using Microsoft.Bot.Connector; + using Microsoft.ProjectOxford.Vision; using Services; [BotAuthentication] @@ -42,7 +43,11 @@ public async Task Post([FromBody]Activity activity) } catch (Exception e) { - message = "Oops! Something went wrong. Try again later (hint: check your APIKEY at web.config)."; + message = "Oops! Something went wrong. Try again later"; + if (e is ClientException && (e as ClientException).Error.Message.ToLowerInvariant().Contains("access denied")) + { + message += " (access denied - hint: check your APIKEY at web.config)."; + } Trace.TraceError(e.ToString()); }