TeamSpeak 3 PHP Framework  1.1.23
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
TeamSpeak3_Helper_Exception Class Reference

Enhanced exception class for TeamSpeak3_Helper_* objects. More...

+ Inheritance diagram for TeamSpeak3_Helper_Exception:

Public Member Functions

 getSender ()
 Returns the class from which the exception was thrown. More...
 

Static Public Member Functions

static registerCustomMessage ($code, $mesg)
 Registers a custom error message to $code. More...
 
static unregisterCustomMessage ($code)
 Unregisters a custom error message from $code. More...
 

Protected Member Functions

 prepareCustomMessage (TeamSpeak3_Helper_String $mesg)
 Prepares a custom error message by replacing pre-defined signs with given values. More...
 

Static Protected Attributes

static $messages = array()
 

Detailed Description

Enhanced exception class for TeamSpeak3_Helper_* objects.

Definition at line 32 of file Exception.php.

Member Function Documentation

TeamSpeak3_Exception::prepareCustomMessage ( TeamSpeak3_Helper_String  $mesg)
protectedinherited

Prepares a custom error message by replacing pre-defined signs with given values.

Parameters
TeamSpeak3_Helper_String$mesg
Returns
TeamSpeak3_Helper_String

Definition at line 66 of file Exception.php.

References TeamSpeak3_Helper_String\arg().

Referenced by TeamSpeak3_Exception\__construct().

67  {
68  $args = array(
69  "code" => $this->getCode(),
70  "mesg" => $this->getMessage(),
71  "line" => $this->getLine(),
72  "file" => $this->getFile(),
73  );
74 
75  return $mesg->arg($args)->toString();
76  }
static TeamSpeak3_Exception::registerCustomMessage (   $code,
  $mesg 
)
staticinherited

Registers a custom error message to $code.

Parameters
integer$code
string$mesg
Exceptions
TeamSpeak3_Exception
Returns
void

Definition at line 86 of file Exception.php.

87  {
88  if(array_key_exists((int) $code, self::$messages))
89  {
90  throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is already registered");
91  }
92 
93  if(!is_string($mesg))
94  {
95  throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " must be a string");
96  }
97 
98  self::$messages[(int) $code] = new TeamSpeak3_Helper_String($mesg);
99  }
static TeamSpeak3_Exception::unregisterCustomMessage (   $code)
staticinherited

Unregisters a custom error message from $code.

Parameters
integer$code
Exceptions
TeamSpeak3_Exception
Returns
void

Definition at line 108 of file Exception.php.

109  {
110  if(!array_key_exists((int) $code, self::$messages))
111  {
112  throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is not registered");
113  }
114 
115  unset(self::$messages[intval($code)]);
116  }
TeamSpeak3_Exception::getSender ( )
inherited

Returns the class from which the exception was thrown.

Returns
string

Definition at line 123 of file Exception.php.

124  {
125  $trace = $this->getTrace();
126 
127  return (isset($trace[0]["class"])) ? $trace[0]["class"] : "{main}";
128  }

The documentation for this class was generated from the following file: