--- nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php 2003/03/29 08:01:21 1.12 +++ nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php 2003/04/04 17:38:03 1.13 @@ -15,9 +15,12 @@ * *
  * -------------------------------------------------------------------------
- *    $Id: RemoteProxy.php,v 1.12 2003/03/29 08:01:21 joko Exp $
+ *    $Id: RemoteProxy.php,v 1.13 2003/04/04 17:38:03 joko Exp $
  * -------------------------------------------------------------------------
  *    $Log: RemoteProxy.php,v $
+ *    Revision 1.13  2003/04/04 17:38:03  joko
+ *    modifications regarding error-/exception-handling and -tracing
+ *
  *    Revision 1.12  2003/03/29 08:01:21  joko
  *    modified ErrorBoxing
  *
@@ -516,31 +519,19 @@
 
     //print "result: " . dumpVar($result) . "
"; - $status = $this->backend->getStatus(); + $status = $this->backend->status(); //print Dumper($status); - $style = html_style("text/css", '.boxlabel_yellow { color: yellow; font-weight:bold; }'); - $statusbox = html_div(); - $statusbox->set_style('background: red; border: 2px black groove; width:640px; padding:10px; margin:40px;'); - $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); - foreach ($status[errors] as $error) { - $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() ); - } - - if (is_array($result)) { - $good = 1; - } else { - $message = get_class($this) . "->_loadRemote: Error while trying to talk to remote side. Please check wire, socket or api."; - logp($message, PEAR_LOG_CRIT); - $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); - } + $good = is_array($result) && sizeof($result) && $status[connected]; - if ($good && sizeof($result)) { + if ($good) { // FIXME: this is dangerous! + /* if ($_GET[debug]) { print Dumper($result); } + */ $this->payload = serialize($result); // ----- move this to _encode some times @@ -550,19 +541,50 @@ $this->flushState(); } else { - if (constants::get('VERBOSE') || constants::get('ERRORS_ONLY')) { - print $style->render(); - print $statusbox->render(); + + if (constants::get('APP_MODE_DEBUG')) { + $this->draw_error_box($status); } else { - foreach ($status[errors] as $error) { - print Dumper($error); - } + php::maintenance('rpc', array( status => $status ) ); } } } + +function draw_error_box($status) { + $style = html_style("text/css", '.boxlabel_yellow { color: yellow; font-weight:bold; }'); + $statusbox = html_div(); + $statusbox->set_style('background: red; border: 2px black groove; width:640px; padding:10px; margin:40px;'); + $statusbox->add( html_span('boxlabel_yellow', "Method:"), get_class($this) . "->_loadRemote", html_br() ); + $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); + $statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); + foreach ($status[errors] as $error) { + $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() ); + } + $message = "Error while talking to remote side. Please check wire, socket or api."; + logp($message, PEAR_LOG_CRIT); + $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); + + // V1 + /* + if (constants::get('VERBOSE') || constants::get('ERRORS_ONLY')) { + print $style->render(); + print $statusbox->render(); + } else { + foreach ($status[errors] as $error) { + print Dumper($error); + } + } + */ + + // V2 + trace( container($style, $statusbox) ); + +} + + function _saveBackend($result) { logp(get_class($this) . "->_saveBackend()");