Skip to content
Louis Charette edited this page Apr 19, 2014 · 1 revision

#List of errors code:

Error code Error value Error description
"001" BAD_PARAMS A needed parameter is missing.
"002" BAD_CMD Unknown command has been sent.
"003" NO_CMD Did not gave a cmd. Maybe you forgot to pass your command in an array [{"cmd":"...](
"004" BAD_SESSID Unknown sessid has been sent.
"005" BAD_JSON The JSON is not well formatted.
"006" BAD_NICK In nickname.js. Nick names can not be more than 16 characters and has to be only alpha numeric.
"007" NICK_USED
"100" ALLREADY_ON_CHANNEL
"103" UNKNOWN_CHANNEL
"104" NOT_IN_CHANNEL
"109" UNKNOWN_PIPE
"110" SETLEVEL_ERROR
"200" UNKNOWN_CONNECTION_ERROR Unknown connection error occurred.
"201" NO_DOMAIN
"202" CANT_JOIN_CHANNEL
"203" SESSON_ERROR
"225-249" Reserved --
"250" BAD_CHL Bad challenge number sent.
"300-325" Reserved --

Please add your own if you are creating a public module.

#Intercepting Errors Errors can be intercepted on the client side using the onError() function.

onError() works as follows:

client.onError('ERROR_CODE', FUNC);

Where: client is the APE.Client() object, ERROR_CODE is the error code (See table above), and FUNC is the callback function triggered when the error occurs.

Example: The user is alerted to a "Bad session id" (004) error.

client = new APE.Client();
 
/* Other code here. */
 
client.onError('004', function () {
    alert('You have a bad session ID. ');
});

#Raising errors It is easy to return a error on the the serverside. ##Ape.registerHookCmd If a command is received, registerHookCmd is checked for a command with that name. If that is present, the appropiate function will be called If it that function a 0 is returned then Ape.registerCmd will be called if in that function a array with two strings is returned, then that error will be send if in that function a non-0 integer is raised, then that error will be send ##Ape.registerCmd registerCmd follows the exact logic as registerHookCmd

##Example

Ape.registerHookCmd("connect", function(params, cmd) {
	if (#$defined(params) || #$defined(params.name)) return 0;
	if (userlist.has(params.name.toLowerCase())) return ["007", "NICK_USED");
	if (params.name.length > 16 || params.name.test('[^a-zA-Z0-9]', 'i')) return ["006", "BAD_NICK"];
	cmd.user.setProperty('name', params.name);	
	return 1; //Raises a ['001', 'BAD_PARAMS']
});
Clone this wiki locally