Throw error from SFS2X JavaScript Extension

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

Pal
Posts: 2
Joined: 24 Oct 2019, 12:37

Throw error from SFS2X JavaScript Extension

Postby Pal » 24 Oct 2019, 12:45

Hi,

I'm currently going a bit mad here, can anybody point me in the right direction?

Currently I am using the latest JS API (1.7.15) along with SFS2X 2.13.6.

I'm throwing an error in JavaScript extension like this:

(I've minimized down the code for the sake of being more readable)

Server Extension:
var SFSLoginException = Java.type('com.smartfoxserver.v2.exceptions.SFSLoginException');
var SFSErrorData = Java.type('com.smartfoxserver.v2.exceptions.SFSErrorData');
var SFSErrorCode = Java.type('com.smartfoxserver.v2.exceptions.SFSErrorCode');

var errData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR);
errData.addParameter("Error thrown from Server");
throw new SFSLoginException("Error thrown from Server", errData);


The error shows up as it should in the smartfox.log too:
WARN | SFSWorker:Ext:2 | Extensions | | <eval>:59:1 com.smartfoxserver.v2.exceptions.SFSLoginException: Error thrown from Server in Extension: ZONE, File: LoginExtension.js


The onLoginError function is the default one:
function onLoginError(evtParams)
{
// Show error
console.log("onLoginError: " + evtParams.errorMessage);
}


However, the onLoginError function is never called when the server throws the error this way and happily continues forward, other errors that are being thrown by SmartFox do show up in the onLoginError function as they should though.


I'm sure I'm overlooking something here, and I'd be happy if somebody could point it out to me.


Thanks!
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Throw error from SFS2X JavaScript Extension

Postby Lapo » 24 Oct 2019, 13:48

Hi,
I was able to reproduce the issue. It looks like from the javascript side the SFSLoginException gets wrapped into a Javascript generic exception type which is not recognized at the server level, and escapes the Logging API.

In order to fix this we should release a patch. If you want you can get in touch with us directly at support@... Make sure to add a reference to this discussion and we'll send the patch for you to test.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Pal
Posts: 2
Joined: 24 Oct 2019, 12:37

Re: Throw error from SFS2X JavaScript Extension

Postby Pal » 24 Oct 2019, 14:01

Hi Lapo,

thanks for your fast response, I emailed you - I'm glad I'm not completely going insane here.


Again, thank you!
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Throw error from SFS2X JavaScript Extension

Postby Lapo » 24 Oct 2019, 14:16

No, indeed :D
We've sent the link to the patch.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: Bax and 17 guests