* @license PHP License * @package Wombat * @subpackage base */ /** * exception * * WBException allows sophisticated exception codes. * While Exception only allows numbers, WBException * supports namespaces for code. * * $e = new WBException( 'my custom message', 7, __CLASS__ ); * * Use namespaces to keep track on your exception codes, using the constant __CLASS__ * may help you in case you are in need for names * * @version 0.3.0 * @package Wombat * @subpackage base */ class WBException extends Exception { /** * Exception code using namespace * @var string */ protected $code = null; /** * constructor * * @param string $msg exception message * @param int $code integer * @param string $clazz name of calling class * @see Exception */ public function __construct($msg, $code = 0, $clazz = '') { if (is_array($msg)) { $args = array( 'msg' => '', 'code' => 0, 'class' => '', ); $args = array_merge($args, $msg); $msg = $args['msg']; $code = $args['code']; $clazz = $args['class']; } $this->message = $msg; $this->code = $clazz . '.' . $code; if (!class_exists('WBLog', false)) { return; } $log = WBLog::start(__CLASS__); $message = array( 'msg' => $msg, 'code' => $code, 'class' => $clazz ); $log->err($message); } } ?>