Skip to content

Error handling #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Nov 20, 2017
Merged

Error handling #302

merged 24 commits into from
Nov 20, 2017

Conversation

mediumTaj
Copy link
Contributor

@mediumTaj mediumTaj commented Nov 14, 2017

Summary

Refactoring SDK to have a success and failure callbacks. We also now pass a dictionary for custom data.

We can now use generic handlers as callbacks for multiple response types. The raw json response is always passed as json in the customData dictionary.

void Start()
{
    //  Call with generic callbacks
    conversation.Message(OnSuccess, OnFail, _workspaceId, "");
    discovery.GetEnvironments(OnSuccess, OnFail);

    //  Call with sepcific callbacks
    conversation.Message(OnMessage, OnGetEnvironmentsFail, _workspaceId, "");
    discovery.GetEnvironments(OnGetEnvironments, OnMessageFail);
}

//  Generic success callback
private void OnSuccess<T>(T resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnSuccess()", "Response received: {0}", customData["json"].ToString());
}

//  Generic fail callback
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnFail()", "Error received: {0}", error.ToString());
}

//  OnMessage callback
private void OnMessage(object resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnMessage()", "Response received: {0}", customData["json"].ToString());
}

//  OnGetEnvironments callback
private void OnGetEnvironments(GetEnvironmentsResponse resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnGetEnvironments()", "Response received: {0}", customData["json"].ToString());
}

//  OnMessageFail callback
private void OnMessageFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnMessageFail()", "Error received: {0}", error.ToString());
}

//  OnGetEnvironmentsFail callback
private void OnGetEnvironmentsFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnGetEnvironmentsFail()", "Error received: {0}", error.ToString());
}

@mediumTaj
Copy link
Contributor Author

@kimberlysiva Can you test this when you have a chance?

…ect ifdef for restconnector security import, incorrect name in document conversion
@kimberlysiva
Copy link
Contributor

@mediumTaj Thanks so much for this! The failure callbacks are great, I'm correctly catching the 409 errors for STT custom language models now.

I've tested STT and Conversation on Mac, Windows, and Hololens. Everything is working great so far!

@mediumTaj mediumTaj merged commit 99d175a into develop Nov 20, 2017
@mediumTaj mediumTaj deleted the 265-error-handling branch November 20, 2017 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants