Exemplo n.º 1
0
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
$html = '<pre>' . strip_tags(get_class($e) . " from " . $e->getFile() . ':' . $e->getLine() . ': ' . $e->getMessage());
$errmsg = "Killed by " . strip_tags(get_class($e) . " from " . $e->getFile() . ':' . $e->getLine() . ': ' . $e->getMessage());
if (MVC_DEV_MODE) {
    if ($e instanceof ABException) {
        $ts = ABException::formatTrace($e, false);
    } else {
        $ts = $e->getTraceAsString();
    }
    $errmsg .= "\n   " . strip_tags(str_replace("\n", "\n   ", $ts));
    $html .= "\n<small>\n   " . strip_tags(str_replace("\n", "\n   ", $ts)) . '</small>';
}
http_error('500 Internal Error', 0, $html . '</pre>');
Exemplo n.º 2
0
 /**
  * @param  string
  * @return void
  */
 protected function importClassFiles($path)
 {
     $org_cwd = getcwd();
     chdir($path);
     foreach (scandir($path) as $file) {
         if ($file[0] == '.') {
             continue;
         }
         $filepath = $path . '/' . $file;
         if (strrchr($file, '.') == '.php') {
             if (!preg_match('/^[A-Z]/', $file)) {
                 continue;
             }
             $guessedClass = substr($file, 0, -4);
             if ($this->log) {
                 $this->log->debug("Loading class %s from %s/%s ... ", $guessedClass, basename($path), basename($file));
             }
             if (!class_exists($guessedClass) && !interface_exists($guessedClass, false)) {
                 $e = new Exception();
                 print "\nFATAL unittest error in " . __FILE__ . ':' . (__LINE__ - 2) . ":\n  Unable to find probable class or interface \"{$guessedClass}\" for file \n" . ABException::formatTrace($e, false);
                 exit(1);
             }
             if ($this->log) {
                 $this->log->debug("OK\n");
             }
         } elseif ($this->recursive && is_dir($filepath) && is_readable($filepath)) {
             # Recurse down the alley...
             $this->importClassFiles($filepath);
         }
     }
     chdir($org_cwd);
 }
Exemplo n.º 3
0
}
$fileLine = "on line {$line} in ";
if (isset($_SERVER['DOCUMENT_ROOT'])) {
    $fileLine .= File::relativePath($file, $_SERVER['DOCUMENT_ROOT']);
} elseif (isset($GLOBALS['argv'][0])) {
    $fileLine .= File::relativePath($file, dirname($GLOBALS['argv'][0]));
} else {
    $fileLine .= $file;
}
switch ($errno) {
    case E_PARSE:
    case E_USER_ERROR:
    case E_ERROR:
        break;
    case E_NOTICE:
    case E_USER_NOTICE:
        if (PHP::isCLI()) {
            IO::writeError("{$GLOBALS['argv'][0]}: WARNING: {$str} {$fileLine}\n");
        } else {
            error_log("WARNING: {$str} {$fileLine}");
        }
        return;
}
if (PHP::isCLI()) {
    IO::writeError("{$GLOBALS['argv'][0]}: FATAL: {$str} {$fileLine}\n\t" . str_replace("\n", "\n\t", ABException::formatTrace(new Exception(), false, array('__errhandler'))) . "\n");
} else {
    $s = ABException::formatTrace(new Exception(), true, array('__errhandler'));
    error_log("FATAL: {$str} ({$fileLine}) {$s}");
    print "<div class=\"err\"><b>FATAL:</b> {$str} <span class=\"file\">{$fileLine}</span>\n" . '<div class="trace">' . $s . '</div>' . '</div>';
}
exit(1);