Can't get error message from a customed error code in iOS Swift

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

igneel
Posts: 3
Joined: 04 Oct 2021, 07:45

Can't get error message from a customed error code in iOS Swift

Postby igneel » 04 Oct 2021, 07:57

Hi, I'm encountering an issue where I can't get the error message from a specific error code (201) that is set up and sent from the server when the client is sending the Login Request.
I know that there are fixed array of code 0 - 42 from here : http://docs2x.smartfoxserver.com/AdvancedTopics/client-error-messages

Is it possible to set the error code and error message beyond 42 ? in my case, it is at 201.
or we should use 28 instead for any custom messages ?

I tried

Code: Select all

let customParam:String = SFSErrorCodes.getErrorMessage(201, params: evt.params["errorCode"] as? [Any])
inside the onLoginError, and still got this :
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 201 beyond bounds [0 .. 42]'


Many thanks in advance!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't get error message from a customed error code in iOS Swift

Postby Lapo » 04 Oct 2021, 09:00

Hi,
I have investigated the issue you have reported and I've noticed that the way this is implemented in the iOS API is different from, say, Java.
Here it is implemented as an array rather than a key/value pair (i.e. map), so new custom messages must use a progressive id.

In other words, since under iOS it is implemented as an NSArray you need to add new custom errors starting at ID=42 and incrementing from there.

I have added a note to our bug database to review this approach and possibly convert to a map, as in the other APIs.

Thanks for reporting
Lapo
--
gotoAndPlay()
...addicted to flash games
igneel
Posts: 3
Joined: 04 Oct 2021, 07:45

Re: Can't get error message from a customed error code in iOS Swift

Postby igneel » 04 Oct 2021, 09:45

Lapo wrote:Hi,
I have investigated the issue you have reported and I've noticed that the way this is implemented in the iOS API is different from, say, Java.
Here it is implemented as an array rather than a key/value pair (i.e. map), so new custom messages must use a progressive id.

In other words, since under iOS it is implemented as an NSArray you need to add new custom errors starting at ID=42 and incrementing from there.

I have added a note to our bug database to review this approach and possibly convert to a map, as in the other APIs.

Thanks for reporting


Hi, Thanks for your reply.
I've tried to set the error message from client side, and still get this error :
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM replaceObjectAtIndex:withObject:]: index 43 beyond bounds [0 .. 42]'

as for the code :

Code: Select all

SFSErrorCodes.setErrorMessage(42, message: "you don't seem to be a human user. Nice try!")
        SFSErrorCodes.setErrorMessage(43, message: "Sorry {0}, you don't seem to be a human user. Nice try!")


it went well for 42 because it is still in the range of 0 - 42, but not for anything > 42
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't get error message from a customed error code in iOS Swift

Postby Lapo » 04 Oct 2021, 13:00

Thanks,
we'll release an update in the next few days. I'll add a post here, when it's ready.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
igneel
Posts: 3
Joined: 04 Oct 2021, 07:45

Re: Can't get error message from a customed error code in iOS Swift

Postby igneel » 04 Oct 2021, 13:27

Lapo wrote:Thanks,
we'll release an update in the next few days. I'll add a post here, when it's ready.

Cheers


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

Re: Can't get error message from a customed error code in iOS Swift

Postby Lapo » 05 Oct 2021, 15:13

Hi,
we have published the new release.
See this post for the details: viewtopic.php?f=21&t=25987&p=98026#p98026

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 20 guests