TroyMunford

Add full error messages to the .NET SDK

0 votes
The following code does not return the specific error message.
 try
            {
                PackageId packageId = eslClient.CreatePackage(documentPackage);
            }
            catch (EslServerException serverException) {
            Console.Out.WriteLine( "The server could not complete the request." );
            Console.Out.WriteLine( serverException.Message );
            Console.Out.WriteLine( "HTTP code: " + serverException.ServerError.Code);
            Console.Out.WriteLine( "Server message: " + serverException.ServerError.Message);
            } 
            catch (EslException exception) {
            Console.Out.WriteLine( exception.Message );
            Console.Out.WriteLine( exception.InnerException.Message );
            }
Using the above code, we included a bad connection string (to a non-existent URL) on purpose, and are getting error message like the following when using the SDK: NOTE: Connection string errors are only throwing a EslException,and never a EslServerException.
Error returned as a string:
 Silanis.ESL.SDK.EslException: Could not get application version. Exception: Unexpected character encountered while parsing value: <. path="" line="" position=""> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. path="" line="" position="" at="" newtonsoft.json.jsontextreader.parsevalue="" newtonsoft.json.jsontextreader.readinternal="" newtonsoft.json.jsontextreader.read="" newtonsoft.json.serialization.jsonserializerinternalreader.readfortype="" reader="" jsoncontract="" contract="" boolean="" hasconverter="" newtonsoft.json.serialization.jsonserializerinternalreader.deserialize="" type="" objecttype="" checkadditionalcontent="" newtonsoft.json.jsonserializer.deserializeinternal="" newtonsoft.json.jsonconvert.deserializeobject="" value="" jsonserializersettings="" settings="" silanis.esl.sdk.systemservice.getapplicationversion="" end="" of="" inner="" exception="" stack="" trace="">
OR when calling the eslClient.SystemService.GetApplicationVersion() with a bad URL:
Silanis.ESL.SDK.EslException: Could not get application version. Exception: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Silanis.ESL.SDK.Internal.HttpMethods.GetHttpJson(String apiToken, String path, String acceptType)
   at Silanis.ESL.SDK.RestClient.Get(String path)
   at Silanis.ESL.SDK.SystemService.GetApplicationVersion()
OR when calling the eslClient.AccountService.GetSenders() with a bad URL:
Silanis.ESL.SDK.EslException: Failed to retrieve Account Members List.	 Exception: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Silanis.ESL.SDK.Internal.HttpMethods.GetHttpJson(String apiToken, String path, String acceptType)
   at Silanis.ESL.SDK.RestClient.Get(String path)
   at Silanis.ESL.SDK.AccountApiClient.GetSenders(Direction direction, PageRequest request)
OR when calling the eSignProvider.CreatePackage() with a bad URL:
Silanis.ESL.SDK.EslException: Could not create a new package. Exception: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Silanis.ESL.SDK.Internal.HttpMethods.PostHttp(String apiToken, String path, Byte[] content)
   at Silanis.ESL.SDK.RestClient.Post(String path, String jsonPayload)
   at Silanis.ESL.SDK.Services.PackageService.CreatePackage(Package package)
I know it couldn't create the package because that's where my caller got the error. I'm far more interested in WHY it couldn't create the package (other than "something was null"). Please provide a way to get the actual errors, codes, etc., in the SDK (Version 11.0.1.0 of the Silanis.ESL.dll). Original post for assistance in the forums: https://developer.esignlive.com/forums/topic/sdk-does-not-expose-error-mesages/#post-5776

Reply to: Add full error messages to the .NET SDK

0 votes
I emphatically agree with this enhancement. When these null reference exceptions show up in an environment, the operations teams always end up going back to developers for root cause analysis. However, if the ESL SDK correctly returned the error ‘Could not connect to server https://abc.com/api’, the operations team could immediately begin triaging networking issues and get the environment up and running without having to round up staff from every team.

Reply to: Add full error messages to the .NET SDK

0 votes
Hi there, This particular enhancement request has been accepted for roadmap consideration. Note that this doesn't necessarily guarantee that the enhancement will be added to the roadmap. Requests are reviewed by a committee on a quarterly basis to determine which candidates can be slotted into the roadmap.
Haris Haidary OneSpan Technical Consultant

Reply to: Add full error messages to the .NET SDK

0 votes
Plus 1 for this enhancement

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off