Changeset 457
- Timestamp:
- 06/15/07 17:21:58 (2 years ago)
- Files:
-
- trunk/lib/jelix/core/jException.lib.php (modified) (5 diffs)
- trunk/lib/jelix/core/jException.lib.php (modified) (5 diffs)
- trunk/testapp/modules/unittest/classes/utcreateurls.class.php (modified) (2 diffs)
- trunk/testapp/modules/unittest/classes/utcreateurls.class.php (modified) (2 diffs)
- trunk/testapp/modules/unittest/classes/utdao_conditions.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utdao_conditions.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utdao_parser.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utdao_parser.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utdao_parser2.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utdao_parser2.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utjdb_profile.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utjdb_profile.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utjtplexpr.class.php (modified) (2 diffs)
- trunk/testapp/modules/unittest/classes/utjtplexpr.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/core/jException.lib.php
r334 r457 18 18 global $gJConfig, $gJCoord; 19 19 20 if($exception instanceof jException){ 21 $msg = $exception->getLocaleMessage(); 22 }else{ 23 $msg = $exception->getMessage(); 24 } 20 $msg = $exception->getMessage(); 25 21 26 22 $conf = $gJConfig->error_handling; … … 28 24 29 25 $doecho=true; 26 30 27 if($gJCoord->request == null){ 28 31 29 $msg = 'JELIX PANIC ! Error during initialization !! '.$msg; 32 30 $doecho = false; 31 33 32 }elseif($gJCoord->response == null){ 33 34 34 $ret = $gJCoord->initDefaultResponseOfRequest(); 35 35 if(is_string($ret)){ … … 106 106 107 107 /** 108 * the locale key 109 * @var string 110 */ 111 protected $localeKey = ''; 112 113 /** 108 114 * parameters for the locale key 109 115 */ 110 public $localeParams = array(); 111 112 /** 113 * the localized message 114 * @var string 115 */ 116 public $localizedMessage = ''; 116 protected $localeParams = array(); 117 117 118 118 /** … … 122 122 */ 123 123 public function __construct($localekey, $localeParams=array(), $code = 1) { 124 125 $this->localeKey = $localekey; 126 $this->localeParams = $localeParams; 127 124 128 try{ 125 $ this->localizedMessage = jLocale::get($localekey, $localeParams);129 $message = jLocale::get($localekey, $localeParams); 126 130 }catch(Exception $e){ 127 $ this->localizedMessage = $e->getMessage();131 $message = $e->getMessage(); 128 132 } 129 if(preg_match('/^\s*\((\d+)\)(.+)$/',$ this->localizedMessage,$m)){133 if(preg_match('/^\s*\((\d+)\)(.+)$/',$message,$m)){ 130 134 $code = $m[1]; 131 $ this->localizedMessage = $m[2];135 $message = $m[2]; 132 136 } 133 parent::__construct($localekey, $code); 134 $this->localeParams=$localeParams; 137 parent::__construct($message, $code); 135 138 } 136 139 … … 139 142 * @return string localized message 140 143 */ 141 public function __toString() {144 /*public function __toString() { 142 145 return $this->localizedMessage; 146 }*/ 147 148 /** 149 * getter for the locale parameters 150 * @return string 151 */ 152 public function getLocaleParameters(){ 153 return $this->localeParams; 143 154 } 144 155 145 156 /** 146 * getter for the local ized message157 * getter for the locale key 147 158 * @return string 148 159 */ 149 public function getLocale Message(){150 return $this->local izedMessage;160 public function getLocaleKey(){ 161 return $this->localeKey; 151 162 } 152 163 trunk/lib/jelix/core/jException.lib.php
r334 r457 18 18 global $gJConfig, $gJCoord; 19 19 20 if($exception instanceof jException){ 21 $msg = $exception->getLocaleMessage(); 22 }else{ 23 $msg = $exception->getMessage(); 24 } 20 $msg = $exception->getMessage(); 25 21 26 22 $conf = $gJConfig->error_handling; … … 28 24 29 25 $doecho=true; 26 30 27 if($gJCoord->request == null){ 28 31 29 $msg = 'JELIX PANIC ! Error during initialization !! '.$msg; 32 30 $doecho = false; 31 33 32 }elseif($gJCoord->response == null){ 33 34 34 $ret = $gJCoord->initDefaultResponseOfRequest(); 35 35 if(is_string($ret)){ … … 106 106 107 107 /** 108 * the locale key 109 * @var string 110 */ 111 protected $localeKey = ''; 112 113 /** 108 114 * parameters for the locale key 109 115 */ 110 public $localeParams = array(); 111 112 /** 113 * the localized message 114 * @var string 115 */ 116 public $localizedMessage = ''; 116 protected $localeParams = array(); 117 117 118 118 /** … … 122 122 */ 123 123 public function __construct($localekey, $localeParams=array(), $code = 1) { 124 125 $this->localeKey = $localekey; 126 $this->localeParams = $localeParams; 127 124 128 try{ 125 $ this->localizedMessage = jLocale::get($localekey, $localeParams);129 $message = jLocale::get($localekey, $localeParams); 126 130 }catch(Exception $e){ 127 $ this->localizedMessage = $e->getMessage();131 $message = $e->getMessage(); 128 132 } 129 if(preg_match('/^\s*\((\d+)\)(.+)$/',$ this->localizedMessage,$m)){133 if(preg_match('/^\s*\((\d+)\)(.+)$/',$message,$m)){ 130 134 $code = $m[1]; 131 $ this->localizedMessage = $m[2];135 $message = $m[2]; 132 136 } 133 parent::__construct($localekey, $code); 134 $this->localeParams=$localeParams; 137 parent::__construct($message, $code); 135 138 } 136 139 … … 139 142 * @return string localized message 140 143 */ 141 public function __toString() {144 /*public function __toString() { 142 145 return $this->localizedMessage; 146 }*/ 147 148 /** 149 * getter for the locale parameters 150 * @return string 151 */ 152 public function getLocaleParameters(){ 153 return $this->localeParams; 143 154 } 144 155 145 156 /** 146 * getter for the local ized message157 * getter for the locale key 147 158 * @return string 148 159 */ 149 public function getLocale Message(){150 return $this->local izedMessage;160 public function getLocaleKey(){ 161 return $this->localeKey; 151 162 } 152 163 trunk/testapp/modules/unittest/classes/utcreateurls.class.php
r386 r457 50 50 $this->assertTrue( ($url == $trueResult[$k]), 'url attendue='.$trueResult[$k].' url créée='.$url ); 51 51 }catch(jExceptionSelector $e){ 52 $this->assertTrue(false,'jExceptionSelector: '.$e->getMessage() );52 $this->assertTrue(false,'jExceptionSelector: '.$e->getMessage().' ('.$e->getLocalKey().')'); 53 53 }catch(jException $e){ 54 $this->assertTrue(false,'jException: '.$e->getMessage() );54 $this->assertTrue(false,'jException: '.$e->getMessage().' ('.$e->getLocalKey().')'); 55 55 }catch(Exception $e){ 56 56 $msgerr = '<br>Survenue : exception=Exception code='.$e->getCode().' msg='.$e->getMessage(); … … 74 74 $this->assertTrue( false, ($res[0]?$msg2:$msg).'<br>Survenue : aucune !!!'); 75 75 }catch(jExceptionSelector $e){ 76 $msgerr = '<br>Survenue : exception=jExceptionSelector code='.$e->getCode().' localkey='.$e->get Message();76 $msgerr = '<br>Survenue : exception=jExceptionSelector code='.$e->getCode().' localkey='.$e->getLocaleKey(); 77 77 $this->assertTrue( ($res[0]==2) ,$msg2.$msgerr); 78 78 }catch(jException $e){ 79 $msgerr = '<br>Survenue : exception=jException code='.$e->getCode().' localkey='.$e->get Message();79 $msgerr = '<br>Survenue : exception=jException code='.$e->getCode().' localkey='.$e->getLocaleKey(); 80 80 $this->assertTrue( ($res[0]==1) ,$msg2.$msgerr); 81 81 }catch(Exception $e){ trunk/testapp/modules/unittest/classes/utcreateurls.class.php
r386 r457 50 50 $this->assertTrue( ($url == $trueResult[$k]), 'url attendue='.$trueResult[$k].' url créée='.$url ); 51 51 }catch(jExceptionSelector $e){ 52 $this->assertTrue(false,'jExceptionSelector: '.$e->getMessage() );52 $this->assertTrue(false,'jExceptionSelector: '.$e->getMessage().' ('.$e->getLocalKey().')'); 53 53 }catch(jException $e){ 54 $this->assertTrue(false,'jException: '.$e->getMessage() );54 $this->assertTrue(false,'jException: '.$e->getMessage().' ('.$e->getLocalKey().')'); 55 55 }catch(Exception $e){ 56 56 $msgerr = '<br>Survenue : exception=Exception code='.$e->getCode().' msg='.$e->getMessage(); … … 74 74 $this->assertTrue( false, ($res[0]?$msg2:$msg).'<br>Survenue : aucune !!!'); 75 75 }catch(jExceptionSelector $e){ 76 $msgerr = '<br>Survenue : exception=jExceptionSelector code='.$e->getCode().' localkey='.$e->get Message();76 $msgerr = '<br>Survenue : exception=jExceptionSelector code='.$e->getCode().' localkey='.$e->getLocaleKey(); 77 77 $this->assertTrue( ($res[0]==2) ,$msg2.$msgerr); 78 78 }catch(jException $e){ 79 $msgerr = '<br>Survenue : exception=jException code='.$e->getCode().' localkey='.$e->get Message();79 $msgerr = '<br>Survenue : exception=jException code='.$e->getCode().' localkey='.$e->getLocaleKey(); 80 80 $this->assertTrue( ($res[0]==1) ,$msg2.$msgerr); 81 81 }catch(Exception $e){ trunk/testapp/modules/unittest/classes/utdao_conditions.class.php
r450 r457 101 101 102 102 }catch(jDaoXmlException $e){ 103 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');103 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 104 104 }catch(Exception $e){ 105 105 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utdao_conditions.class.php
r450 r457 101 101 102 102 }catch(jDaoXmlException $e){ 103 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');103 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 104 104 }catch(Exception $e){ 105 105 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utdao_parser.class.php
r449 r457 193 193 $this->assertComplexIdenticalStr($p, $t[1]); 194 194 }catch(jDaoXmlException $e){ 195 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');195 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 196 196 }catch(Exception $e){ 197 197 $this->fail("Exception inconnue : ".$e->getMessage()); … … 307 307 $this->fail("Pas d'exception survenue !"); 308 308 }catch(jDaoXmlException $e){ 309 $this->assertEqual($e->get Message(), $t[1]);310 $this->assertEqual($e-> localeParams, $t[2]);309 $this->assertEqual($e->getLocaleKey(), $t[1]); 310 $this->assertEqual($e->getLocaleParameters(), $t[2]); 311 311 }catch(Exception $e){ 312 312 $this->fail("Exception inconnue : ".$e->getMessage()); … … 406 406 $this->assertComplexIdenticalStr($p, $t[1]); 407 407 }catch(jDaoXmlException $e){ 408 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');408 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 409 409 }catch(Exception $e){ 410 410 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utdao_parser.class.php
r449 r457 193 193 $this->assertComplexIdenticalStr($p, $t[1]); 194 194 }catch(jDaoXmlException $e){ 195 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');195 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 196 196 }catch(Exception $e){ 197 197 $this->fail("Exception inconnue : ".$e->getMessage()); … … 307 307 $this->fail("Pas d'exception survenue !"); 308 308 }catch(jDaoXmlException $e){ 309 $this->assertEqual($e->get Message(), $t[1]);310 $this->assertEqual($e-> localeParams, $t[2]);309 $this->assertEqual($e->getLocaleKey(), $t[1]); 310 $this->assertEqual($e->getLocaleParameters(), $t[2]); 311 311 }catch(Exception $e){ 312 312 $this->fail("Exception inconnue : ".$e->getMessage()); … … 406 406 $this->assertComplexIdenticalStr($p, $t[1]); 407 407 }catch(jDaoXmlException $e){ 408 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage().' ('.$e->getMessage().')');408 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 409 409 }catch(Exception $e){ 410 410 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utdao_parser2.class.php
r450 r457 308 308 $this->assertComplexIdenticalStr($p, $t[1]); 309 309 }catch(jDaoXmlException $e){ 310 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage());310 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage()); 311 311 }catch(Exception $e){ 312 312 $this->fail("Exception inconnue : ".$e->getMessage()); … … 357 357 $this->fail("Pas d'exception survenue !"); 358 358 }catch(jDaoXmlException $e){ 359 $this->assertEqual($e->get Message(), $t[1]);360 $this->assertEqual($e-> localeParams, $t[2]);359 $this->assertEqual($e->getLocaleKey(), $t[1]); 360 $this->assertEqual($e->getLocaleParameters(), $t[2]); 361 361 }catch(Exception $e){ 362 362 $this->fail("Exception inconnue : ".$e->getMessage()); … … 393 393 $this->fail("Pas d'exception survenue !"); 394 394 }catch(jDaoXmlException $e){ 395 $this->assertEqual($e->get Message(), 'jelix~daoxml.method.update.forbidden');396 $this->assertEqual($e-> localeParams, array('','','tryupdate'));395 $this->assertEqual($e->getLocaleKey(), 'jelix~daoxml.method.update.forbidden'); 396 $this->assertEqual($e->getLocaleParameters(), array('','','tryupdate')); 397 397 }catch(Exception $e){ 398 398 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utdao_parser2.class.php
r450 r457 308 308 $this->assertComplexIdenticalStr($p, $t[1]); 309 309 }catch(jDaoXmlException $e){ 310 $this->fail("Exception sur le contenu xml inattendue : ".$e->get LocaleMessage());310 $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage()); 311 311 }catch(Exception $e){ 312 312 $this->fail("Exception inconnue : ".$e->getMessage()); … … 357 357 $this->fail("Pas d'exception survenue !"); 358 358 }catch(jDaoXmlException $e){ 359 $this->assertEqual($e->get Message(), $t[1]);360 $this->assertEqual($e-> localeParams, $t[2]);359 $this->assertEqual($e->getLocaleKey(), $t[1]); 360 $this->assertEqual($e->getLocaleParameters(), $t[2]); 361 361 }catch(Exception $e){ 362 362 $this->fail("Exception inconnue : ".$e->getMessage()); … … 393 393 $this->fail("Pas d'exception survenue !"); 394 394 }catch(jDaoXmlException $e){ 395 $this->assertEqual($e->get Message(), 'jelix~daoxml.method.update.forbidden');396 $this->assertEqual($e-> localeParams, array('','','tryupdate'));395 $this->assertEqual($e->getLocaleKey(), 'jelix~daoxml.method.update.forbidden'); 396 $this->assertEqual($e->getLocaleParameters(), array('','','tryupdate')); 397 397 }catch(Exception $e){ 398 398 $this->fail("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utjdb_profile.class.php
r444 r457 55 55 $this->fail('getting a wrong profil doesn\'t generate an exception'); 56 56 }catch(jException $e){ 57 $this->assertEqual($e->get Message(),'jelix~db.error.profil.unknow', 'wrong exception on getting a wrong profil ('.$e->getMessage().')');57 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.unknow', 'wrong exception on getting a wrong profil ('.$e->getLocaleKey().')'); 58 58 } 59 59 … … 62 62 $this->fail('getting a wrong profil option doesn\'t generate an exception'); 63 63 }catch(jException $e){ 64 $this->assertEqual($e->get Message(),'jelix~db.error.profil.type.unknow', 'wrong exception on getting a wrong profil option ('.$e->getMessage().')');64 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.type.unknow', 'wrong exception on getting a wrong profil option ('.$e->getLocaleKey().')'); 65 65 } 66 66 … … 69 69 $this->fail('getting a profil option with a wrong name doesn\'t generate an exception'); 70 70 }catch(jException $e){ 71 $this->assertEqual($e->get Message(),'jelix~db.error.profil.unknow', 'wrong exception on getting a profil option with a wrong name ('.$e->getMessage().')');71 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.unknow', 'wrong exception on getting a profil option with a wrong name ('.$e->getLocaleKey().')'); 72 72 } 73 73 } trunk/testapp/modules/unittest/classes/utjdb_profile.class.php
r444 r457 55 55 $this->fail('getting a wrong profil doesn\'t generate an exception'); 56 56 }catch(jException $e){ 57 $this->assertEqual($e->get Message(),'jelix~db.error.profil.unknow', 'wrong exception on getting a wrong profil ('.$e->getMessage().')');57 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.unknow', 'wrong exception on getting a wrong profil ('.$e->getLocaleKey().')'); 58 58 } 59 59 … … 62 62 $this->fail('getting a wrong profil option doesn\'t generate an exception'); 63 63 }catch(jException $e){ 64 $this->assertEqual($e->get Message(),'jelix~db.error.profil.type.unknow', 'wrong exception on getting a wrong profil option ('.$e->getMessage().')');64 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.type.unknow', 'wrong exception on getting a wrong profil option ('.$e->getLocaleKey().')'); 65 65 } 66 66 … … 69 69 $this->fail('getting a profil option with a wrong name doesn\'t generate an exception'); 70 70 }catch(jException $e){ 71 $this->assertEqual($e->get Message(),'jelix~db.error.profil.unknow', 'wrong exception on getting a profil option with a wrong name ('.$e->getMessage().')');71 $this->assertEqual($e->getLocaleKey(),'jelix~db.error.profil.unknow', 'wrong exception on getting a profil option with a wrong name ('.$e->getLocaleKey().')'); 72 72 } 73 73 } trunk/testapp/modules/unittest/classes/utjtplexpr.class.php
r435 r457 131 131 $this->assertEqualOrDiff($t, $res); 132 132 }catch(jException $e){ 133 $this->fail("Test '$k', Exception jelix inconnue : ".$e->get LocaleMessage());133 $this->fail("Test '$k', Exception jelix inconnue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 134 134 }catch(Exception $e){ 135 135 $this->fail("Test '$k', Exception inconnue : ".$e->getMessage()); … … 144 144 try{ 145 145 $res = $compil->testParseVarExpr($k); 146 $this->fail("Exception non survenu pour le test '$k' : ".$e->getMessage());146 $this->fail("Exception non survenu pour le test '$k' "); 147 147 }catch(jException $e){ 148 //$this->sendMessage($e->get LocaleMessage());149 $this->assertEqualOrDiff($t[0], $e->get Message());150 $this->assertEqual($t[1], $e-> localeParams);148 //$this->sendMessage($e->getMessage()); 149 $this->assertEqualOrDiff($t[0], $e->getLocaleKey()); 150 $this->assertEqual($t[1], $e->getLocaleParameters()); 151 151 }catch(Exception $e){ 152 152 $this->pass("Exception inconnue : ".$e->getMessage()); trunk/testapp/modules/unittest/classes/utjtplexpr.class.php
r435 r457 131 131 $this->assertEqualOrDiff($t, $res); 132 132 }catch(jException $e){ 133 $this->fail("Test '$k', Exception jelix inconnue : ".$e->get LocaleMessage());133 $this->fail("Test '$k', Exception jelix inconnue : ".$e->getMessage().' ('.$e->getLocalKey().')'); 134 134 }catch(Exception $e){ 135 135 $this->fail("Test '$k', Exception inconnue : ".$e->getMessage()); … … 144 144 try{ 145 145 $res = $compil->testParseVarExpr($k); 146 $this->fail("Exception non survenu pour le test '$k' : ".$e->getMessage());146 $this->fail("Exception non survenu pour le test '$k' "); 147 147 }catch(jException $e){ 148 //$this->sendMessage($e->get LocaleMessage());149 $this->assertEqualOrDiff($t[0], $e->get Message());150 $this->assertEqual($t[1], $e-> localeParams);148 //$this->sendMessage($e->getMessage()); 149 $this->assertEqualOrDiff($t[0], $e->getLocaleKey()); 150 $this->assertEqual($t[1], $e->getLocaleParameters()); 151 151 }catch(Exception $e){ 152 152 $this->pass("Exception inconnue : ".$e->getMessage());
