• Examples (iOS)
• Examples (Java/Android)
• Examples (C++)
Server API Documentation

 

» Client error messages and their customization

The SmartFoxServer 2X client API fire a number of events which notify errors occurred during the interaction with the server, like: SFSEvent.ROOM_CREATION_ERROR, SFSEvent.ROOM_JOIN_ERROR, SFSEvent.ROOM_NAME_CHANGE_ERROR, etc (check the SFSEvent documentation for more errors).
Almost all error-related events contain the following two parameters:

Error messages are built starting from a template text containing placeholders used to add specific details like Zone and Room names and more. It is possible to customize error messages, for example to translate them to other languages, by means of the SFSErrorCodes.setErrorMessage static method. The SFSErrorCodes class is contained in the following package depending on the client language:

In order to customize the error, during the initialization of your application pass the error code and customized text to the above method, like in the following example. Make sure you keep the placeholders to avoid exceptions to be raised.

SFSErrorCodes.SetErrorMessage(13, "Le Groupe demandé n'est pas disponible - Salle: {0}; Groupe: {1}");
SFS2X.SFSErrorCodes.setErrorMessage(13, "Le Groupe demandé n'est pas disponible - Salle: {0}; Groupe: {1}");
SFSErrorCodes.setErrorMessage(13, "Le Groupe demandé n'est pas disponible - Salle: {0}; Groupe: {1}");

The following table lists all the possible error codes, the message templates and the content of the placeholders. Please note that in the Java client API, %s and %d are used instead of {n} placeholders (%s is used for strings, while %d is used for numerical values).

Code Message Placeholders
0 Client API version is obsolete: {0}; required version: {1}

0: current API version
1: minimum API version required

1 Requested Zone {0} does not exist 0: Zone name
2 User name {0} is not recognized 0: user name
3 Wrong password for user {0} 0: user name
4 User {0} is banned 0: user name
5 Zone {0} is full 0: Zone name
6 User {0} is already logged in Zone {1}

0: user name
1: Zone name

7 The server is full
8 Zone {0} is currently inactive 0: Zone name
9 User name {0} contains bad words; filtered: {1} 0: passed user name
1: filtered user name
10 Guest users not allowed in Zone {0} 0: Zone name
11 IP address {0} is banned 0: banned IP address
12 A Room with the same name already exists: {0} 0: Room name
13 Requested Group is not available - Room: {0}; Group: {1}

0: Room name
1: Group name

14 Bad Room name length - Min: {0}; max: {1}; passed name length: {2}

0: minimum Room name lenght
1: maximum Room name lenght
2: passed Room name lenght

15 Room name contains bad words: {0} 0: Room name
16 Zone is full; can't add Rooms anymore
17 You have exceeded the number of Rooms that you can create per session: {0} 0: maximum number of Rooms
18 Room creation failed, wrong parameter: {0} 0: wrong parameter name
19 User {0} already joined in Room 0: user name
20 Room {0} is full 0: Room name
21 Wrong password for Room {0} 0: Room name
22 Requested Room does not exist
23 Room {0} is locked 0: Room name
24 Group {0} is already subscribed 0: Group name
25 Group {0} does not exist 0: Group name
26 Group {0} is not subscribed 0: Group name
27 Group {0} does not exist 0: Group name
28 {0} 0: generic error message
29 Room permission error; Room {0} cannot be renamed 0: Room name
30 Room permission error; Room {0} cannot change password state 0: Room name
31 Room permission error; Room {0} cannot change capacity 0: Room name
32 Switch user error; no player slots available in Room {0} 0: Room name
33 Switch user error; no spectator slots available in Room {0} 0: Room name
34 Switch user error; Room {0} is not a Game Room 0: Room name
35 Switch user error; you are not joined in Room {0} 0: Room name
36 Buddy Manager initialization error, could not load buddy list: {0} 0: error message
37 Buddy Manager error, your buddy list is full; size is {0} 0: maximum buddy list size
38 Buddy Manager error, was not able to block buddy {0} because offline 0: buddy name
39 Buddy Manager error, you are attempting to set too many Buddy Variables; limit is {0} 0: maximum number of Buddy Variables
40 Game {0} access denied, user does not match access criteria 0: Game Room name
41 QuickJoinGame action failed: no matching Rooms were found
42 Your previous invitation reply was invalid or arrived too late