Changeset 786

Show
Ignore:
Timestamp:
08/08/07 22:33:48 (1 year ago)
Author:
schst
Message:

Improved error handling and debugging output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php

    r777 r786  
    151151            try { 
    152152                $jsCode = $generator->generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 
    153             } catch (stubClassNotFoundException $e) { 
     153            } catch (Exception $e) { 
    154154                if ($this->serviceConfig['use-firebug'] === true) { 
    155                     $jsCode = $jsCode . "console.error('Class {$serviceConfig['className']} does not exist, generation of proxy failed.');\n"; 
     155                    $jsCode = $jsCode . "console.error('Generation of proxy for {$serviceConfig['className']} failed.');\n"; 
     156                    $jsCode = $jsCode . $this->convertStringToFirebug($e->__toString()); 
    156157                } 
    157158            } 
     
    337338        return $configFile; 
    338339    } 
     340 
     341    /** 
     342     * Converts any string to Javascript code that writes 
     343     * messages to the firebug console 
     344     * 
     345     * @param string $string 
     346     * @param string $level 
     347     * @return string 
     348     */ 
     349    protected function convertStringToFirebug($string, $level = 'error') { 
     350        $result = ''; 
     351        $lines = explode("\n", $string); 
     352        foreach ($lines as $line) { 
     353            $result .= "console.{$level}('" . addslashes($line) . "');\n"; 
     354        } 
     355        return $result; 
     356    } 
    339357} 
    340358?>