Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * TSqlMapException is the base exception class for all SqlMap exceptions.
5
 *
6
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
7
 * @version $Id: TSqlMapException.php 2541 2008-10-21 15:05:13Z qiang.xue $
8
 * @package System.Data.SqlMap
9
 * @since 3.1
10
 */
11
class TSqlMapException extends TException
12
{
13
	/**
14
	 * Constructor, similar to the parent constructor. For parameters that
15
	 * are of SimpleXmlElement, the tag name and its attribute names and values
16
	 * are expanded into a string.
17
	 */
18
	public function __construct($errorMessage)
19
	{
20
		$this->setErrorCode($errorMessage);
21
		$errorMessage=$this->translateErrorMessage($errorMessage);
22
		$args=func_get_args();
23
		array_shift($args);
24
		$n=count($args);
25
		$tokens=array();
26
		for($i=0;$i<$n;++$i)
27
		{
28
			if($args[$i] instanceof SimpleXmlElement)
29
				$tokens['{'.$i.'}']=$this->implodeNode($args[$i]);
30
			else
31
				$tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]);
32
		}
33
		parent::__construct(strtr($errorMessage,$tokens));
34
	}
35
 
36
	/**
37
	 * @param SimpleXmlElement node
38
	 * @return string tag name and attribute names and values.
39
	 */
40
	protected function implodeNode($node)
41
	{
42
		$attributes=array();
43
		foreach($node->attributes() as $k=>$v)
44
			$attributes[]=$k.'="'.(string)$v.'"';
45
		return '<'.$node->getName().' '.implode(' ',$attributes).'>';
46
	}
47
 
48
	/**
49
	 * @return string path to the error message file
50
	 */
51
	protected function getErrorMessageFile()
52
	{
53
		$lang=Prado::getPreferredLanguage();
54
		$dir=dirname(__FILE__);
55
		$msgFile=$dir.'/messages-'.$lang.'.txt';
56
		if(!is_file($msgFile))
57
			$msgFile=$dir.'/messages.txt';
58
		return $msgFile;
59
	}
60
}
61
 
62
/**
63
 * TSqlMapConfigurationException, raised during configuration file parsing.
64
 *
65
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
66
 * @version $Id: TSqlMapException.php 2541 2008-10-21 15:05:13Z qiang.xue $
67
 * @package System.Data.SqlMap
68
 * @since 3.1
69
 */
70
class TSqlMapConfigurationException extends TSqlMapException
71
{
72
 
73
}
74
 
75
/**
76
 * TSqlMapUndefinedException, raised when mapped statemented are undefined.
77
 *
78
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
79
 * @version $Id: TSqlMapException.php 2541 2008-10-21 15:05:13Z qiang.xue $
80
 * @package System.Data.SqlMap
81
 * @since 3.1
82
 */
83
class TSqlMapUndefinedException extends TSqlMapException
84
{
85
 
86
}
87
 
88
/**
89
 * TSqlMapDuplicateException, raised when a duplicate mapped statement is found.
90
 *
91
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
92
 * @version $Id: TSqlMapException.php 2541 2008-10-21 15:05:13Z qiang.xue $
93
 * @package System.Data.SqlMap
94
 * @since 3.1
95
 */
96
class TSqlMapDuplicateException extends TSqlMapException
97
{
98
}
99
 
100
/**
101
 * TInvalidPropertyException, raised when setting or getting an invalid property.
102
 *
103
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
104
 * @version $Id: TSqlMapException.php 2541 2008-10-21 15:05:13Z qiang.xue $
105
 * @package System.Data.SqlMap
106
 * @since 3.1
107
 */
108
class TInvalidPropertyException extends TSqlMapException
109
{
110
}
111
 
112
class TSqlMapExecutionException extends TSqlMapException
113
{
114
}
115