Changeset 574

Show
Ignore:
Timestamp:
04/19/07 22:11:34 (2 years ago)
Author:
schst
Message:

Handle errors while loading classes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/info/phing/tasks/stubInitTask.php

    r571 r574  
    77 * @package     stubbles 
    88 * @subpackage  phing 
    9  * 
    10  * @todo        Try to catch errors and let the build fail 
    119 */ 
    1210/** 
     
    5149    public function main() 
    5250    { 
    53         require_once $this->configPath . '/php/config.php'; 
     51        @include_once $this->configPath . '/php/config.php'; 
     52        if (!class_exists('stubConfig', false)) { 
     53            $this->log('Error loading Stubbles configuration from ' . $this->configPath . '/php/config.php', Project::MSG_ERR); 
     54            throw new BuildException('Error loading Stubbles configuration from ' . $this->configPath . '/php/config.php'); 
     55        } 
    5456        if (stubConfig::useStar() == true) { 
    55             require_once stubConfig::getLibPath() . '/stubbles.php'; 
     57            if (!@include_once stubConfig::getLibPath() . '/stubbles.php') { 
     58                $this->log('Error loading Stubbles library from ' . stubConfig::getLibPath() . '/stubbles.php', Project::MSG_ERR); 
     59                $this->log('Either stubConfig::getLibPath() is not correctly set, or stubbles.php does not exist.', Project::MSG_ERR); 
     60                throw new BuildException('Error loading Stubbles library from ' . stubConfig::getLibPath() . '/stubbles.php'); 
     61            } 
    5662        } else { 
    57             require_once stubConfig::getLibPath() . '/starReader.php'; 
    58             require_once stubConfig::getSourcePath() . '/php/net/stubbles/stubClassLoader.php'; 
     63            if (!@include_once stubConfig::getLibPath() . '/starReader.php') { 
     64                $this->log('Error loading StarReader from ' . stubConfig::getLibPath() . '/starReader.php', Project::MSG_ERR); 
     65                $this->log('Either stubConfig::getLibPath() is not correctly set, or starReader.php does not exist.', Project::MSG_ERR); 
     66                throw new BuildException('Error loading StarReader from ' . stubConfig::getLibPath() . '/starReader.php'); 
     67            } 
     68            if (!@include_once stubConfig::getSourcePath() . '/php/net/stubbles/stubClassLoader.php') { 
     69                $this->log('Error loading stubClassLoader from ' . stubConfig::getSourcePath() . '/php/net/stubbles/stubClassLoader.php', Project::MSG_ERR); 
     70                $this->log('Either stubConfig::getSourcePath() is not correctly set, or you are not using a source distribution.', Project::MSG_ERR); 
     71                throw new BuildException('Error loading stubClassLoader from ' . stubConfig::getSourcePath() . '/php/net/stubbles/stubClassLoader.php'); 
     72            } 
    5973        } 
    6074