Changeset 287
- Timestamp:
- 11/04/07 14:59:39 (10 months ago)
- Files:
-
- branches/2.3/classes/phing/BuildException.php (modified) (2 diffs)
- branches/2.3/classes/phing/ConfigurationException.php (added)
- branches/2.3/classes/phing/Phing.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.3/classes/phing/BuildException.php
r123 r287 29 29 class BuildException extends Exception { 30 30 31 /** location in the xml file */ 32 protected $location = null; 31 /** 32 * Location in the xml file. 33 * @var Location 34 */ 35 protected $location; 33 36 34 /** The nested "cause" exception. */ 37 /** 38 * The nested "cause" exception. 39 * @var Exception 40 */ 35 41 protected $cause; 36 42 … … 85 91 } 86 92 87 function getCause() { 93 /** 94 * Gets the cause exception. 95 * 96 * @return Exception 97 */ 98 public function getCause() { 88 99 return $this->cause; 89 100 } 90 101 91 function getLocation() { 102 /** 103 * Gets the location of error in XML file. 104 * 105 * @return Location 106 */ 107 public function getLocation() { 92 108 return $this->location; 93 109 } 94 110 95 function setLocation($loc) { 111 /** 112 * Sets the location of error in XML file. 113 * 114 * @param Locaiton $loc 115 */ 116 public function setLocation(Location $loc) { 96 117 $this->location = $loc; 97 118 $this->message = $loc->toString() . ': ' . $this->message; branches/2.3/classes/phing/Phing.php
r280 r287 26 26 27 27 include_once 'phing/BuildException.php'; 28 include_once 'phing/ConfigurationException.php'; 28 29 include_once 'phing/BuildEvent.php'; 29 30 … … 164 165 $m->runBuild(); 165 166 } catch(Exception $exc) { 166 if (self::$msgOutputLevel >= Project::MSG_VERBOSE) { 167 self::$out->write($exc->__toString() . PHP_EOL); 168 } else { 169 self::$out->write($exc->getMessage() . PHP_EOL); 167 if ($exc instanceof ConfigurationException) { 168 if (self::$msgOutputLevel >= Project::MSG_VERBOSE) { 169 self::$out->write($exc->__toString() . PHP_EOL); 170 } else { 171 self::$out->write($exc->getMessage() . PHP_EOL); 172 } 170 173 } 171 174 self::handleLogfile(); … … 302 305 if (!isset($args[$i+1])) { 303 306 $msg = "You must specify a log file when using the -logfile argument\n"; 304 throw new BuildException($msg);307 throw new ConfigurationException($msg); 305 308 } else { 306 309 $logFile = new PhingFile($args[++$i]); … … 312 315 } catch (IOException $ioe) { 313 316 $msg = "Cannot write on the specified log file. Make sure the path exists and you have write permissions."; 314 throw new BuildException($msg, $ioe);317 throw new ConfigurationException($msg, $ioe); 315 318 } 316 319 } elseif ($arg == "-buildfile" || $arg == "-file" || $arg == "-f") { 317 320 if (!isset($args[$i+1])) { 318 321 $msg = "You must specify a buildfile when using the -buildfile argument."; 319 throw new BuildException($msg);322 throw new ConfigurationException($msg); 320 323 } else { 321 324 $this->buildFile = new PhingFile($args[++$i]); … … 324 327 if (!isset($args[$i+1])) { 325 328 $msg = "You must specify a listener class when using the -listener argument"; 326 throw new BuildException($msg);329 throw new ConfigurationException($msg); 327 330 } else { 328 331 $this->listeners[] = $args[++$i]; … … 342 345 if (!isset($args[$i+1])) { 343 346 $msg = "You must specify a classname when using the -logger argument"; 344 throw new BuildException($msg);347 throw new ConfigurationException($msg); 345 348 } else { 346 349 $this->loggerClassname = $args[++$i]; … … 348 351 } elseif ($arg == "-inputhandler") { 349 352 if ($this->inputHandlerClassname !== null) { 350 throw new BuildException("Only one input handler class may be specified.");353 throw new ConfigurationException("Only one input handler class may be specified."); 351 354 } 352 355 if (!isset($args[$i+1])) { 353 356 $msg = "You must specify a classname when using the -inputhandler argument"; 354 throw new BuildException($msg);357 throw new ConfigurationException($msg); 355 358 } else { 356 359 $this->inputHandlerClassname = $args[++$i]; … … 388 391 // make sure buildfile exists 389 392 if (!$this->buildFile->exists()) { 390 throw new BuildException("Buildfile: " . $this->buildFile->__toString() . " does not exist!");393 throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " does not exist!"); 391 394 } 392 395 393 396 // make sure it's not a directory 394 397 if ($this->buildFile->isDirectory()) { 395 throw new BuildException("Buildfile: " . $this->buildFile->__toString() . " is a dir!");398 throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " is a dir!"); 396 399 } 397 400 … … 439 442 // complain that we can't find the build file. 440 443 if ($parent === null) { 441 throw new BuildException("Could not locate a build file!");444 throw new ConfigurationException("Could not locate a build file!"); 442 445 } 443 446 // refresh our file handle … … 561 564 . "class " . $listenerClassname . " : " 562 565 . $e->getMessage(); 563 throw new BuildException($msg);566 throw new ConfigurationException($msg); 564 567 } 565 568 … … 567 570 568 571 if ($listener instanceof StreamRequiredBuildLogger) { 569 throw new BuildException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)");572 throw new ConfigurationException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)"); 570 573 } 571 574 $project->addBuildListener($listener); … … 595 598 . "class " . $this->inputHandlerClassname . " : " 596 599 . $e->getMessage(); 597 throw new BuildException($msg);600 throw new ConfigurationException($msg); 598 601 } 599 602 } … … 781 784 $phingVersion = $buffer; 782 785 } catch (IOException $iox) { 783 throw new BuildException("Can't read version information file");786 throw new ConfigurationException("Can't read version information file"); 784 787 } 785 788 return $phingVersion; … … 977 980 $msg .= $x->getTraceAsString(); 978 981 } 979 throw new BuildException($msg);982 throw new ConfigurationException($msg); 980 983 } 981 984 }
