<?php namespace KIF\Exception; use Exception; /** * * 数据访问层异常 * @author gaoxiaogang@gmail.com * */ class DaoException extends Exception { public function __construct ($message = 'Dao exception', $code = 0) { parent::__construct($message, $code); } /** * * 缓存服务不可用 * @var string */ const CACHE_SERVICE_UNAVAILABLE = 'CACHE_SERVICE_UNAVAILABLE'; /** * * 设置表缓存标志失败 * @var string */ const CACHE_SET_TABLE_FLAG_ERROR = 'CACHE_SET_TABLE_FLAG_ERROR'; /** * * 获取异常描述 * @return array */ static public function getDesc() { return array( self::CACHE_SERVICE_UNAVAILABLE => array( 'kw' => 'CACHE_SERVICE_UNAVAILABLE', 'desc' => '缓存服务不可用', ), self::CACHE_SET_TABLE_FLAG_ERROR => array( 'kw' => 'CACHE_SET_TABLE_FLAG_ERROR', 'desc' => '设置表缓存标志失败', ), ); } /** * * 根据异常的关键词获取文本型的描述 * @param string $kw * @return false | string */ static public function getTextDescByKW($kw) { $descs = self::getDesc(); if (isset($descs[$kw])) { return $descs[$kw]['desc']; } return false; } }