Skip to content

Commit

Permalink
Merge pull request #40 from Geokureli/handle_fail
Browse files Browse the repository at this point in the history
Handle fail
  • Loading branch information
Geokureli authored Aug 20, 2019
2 parents 135bb55 + b48d8e1 commit 946c5ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "newgrounds",
"description" : "Newgrounds API for haxe",
"version" : "1.1.1",
"version" : "1.1.2",
"releasenote" : "remove OpenFL references in NG.hx",
"url" : "https://github.com/Geokureli/Newgrounds.hx",
"classPath" : "lib/Source",
Expand Down
14 changes: 10 additions & 4 deletions lib/Source/io/newgrounds/NGLite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class NGLite {

calls.app.checkSession()
.addDataHandler(checkInitialSession.bind(onSessionFail))
.addErrorHandler(initialSessionFail.bind(onSessionFail))
.send();
}
}
Expand All @@ -82,13 +83,18 @@ class NGLite {

if (!response.success || !response.result.success || response.result.data.session.expired) {

sessionId = null;

if (onFail != null)
onFail(response.success ? response.result.error : response.error);
initialSessionFail(onFail, response.success ? response.result.error : response.error);
}
}

function initialSessionFail(onFail:Error->Void, error:Error):Void {

sessionId = null;

if (onFail != null)
onFail(error);
}

/**
* Creates NG.core, the heart and soul of the API. This is not the only way to create an instance,
* nor is NG a forced singleton, but it's the only way to set the static NG.core.
Expand Down

0 comments on commit 946c5ba

Please sign in to comment.