From 747268c970249c3fed16ff4d9f25fc391d071b22 Mon Sep 17 00:00:00 2001 From: Joshua Holmgren Date: Tue, 15 Jul 2014 10:45:23 -0600 Subject: [PATCH] added reference for System.Drawing.dll, also returning more descriptive error messages from API --- example/build.sh | 2 +- module/AlchemyAPI.cs | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/example/build.sh b/example/build.sh index cc9f672..2a1c9a8 100755 --- a/example/build.sh +++ b/example/build.sh @@ -32,5 +32,5 @@ dmcs taxonomy.cs -r:System.Data.dll -r:System.Web.dll -r:../module/AlchemyAPI.dl dmcs image.cs -r:System.Data.dll -r:System.Web.dll -r:../module/AlchemyAPI.dll -dmcs ranked_image_keywords.cs -r:System.Data.dll -r:System.Web.dll -r:../module/AlchemyAPI.dll +dmcs ranked_image_keywords.cs -r:System.Data.dll -r:System.Web.dll -r:../module/AlchemyAPI.dll -r:System.Drawing.dll diff --git a/module/AlchemyAPI.cs b/module/AlchemyAPI.cs index 60144dc..4b7a25d 100644 --- a/module/AlchemyAPI.cs +++ b/module/AlchemyAPI.cs @@ -955,8 +955,18 @@ private string DoRequest(HttpWebRequest wreq, AlchemyAPI_BaseParams.OutputMode o if (status.InnerText != "OK") { - System.ApplicationException ex = - new System.ApplicationException ("Error making API call."); + string errorMessage = "Error making API call."; + + try + { + XmlNode statusInfo = root.SelectSingleNode("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/results/statusInfo"); + errorMessage = statusInfo.InnerText; + } + catch + { + errorMessage = "An error occurred: Unable to access XmlNode /results/statusInfo"; + } + System.ApplicationException ex = new System.ApplicationException (errorMessage); throw ex; } @@ -970,8 +980,18 @@ private string DoRequest(HttpWebRequest wreq, AlchemyAPI_BaseParams.OutputMode o if (status.InnerText != "OK") { - System.ApplicationException ex = - new System.ApplicationException ("Error making API call."); + string errorMessage = "Error making API call."; + + try + { + XmlNode statusInfo = root.SelectSingleNode("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/results/statusInfo"); + errorMessage = statusInfo.InnerText; + } + catch + { + errorMessage = "An error occurred: Unable to access XmlNode /results/statusInfo"; + } + System.ApplicationException ex = new System.ApplicationException (errorMessage); throw ex; }