Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Report json errors to the user

  • Loading branch information...
commit d0a1f77d67260a23f64a78de3236ddf578de5d27 1 parent ab4852f
@LegNeato LegNeato authored
Showing with 24 additions and 11 deletions.
  1. +17 −11 BugzillaOutput.class.php
  2. +7 −0 templates/error.tpl
View
28 BugzillaOutput.class.php
@@ -8,37 +8,43 @@
public function __construct($config, $options, $title='') {
$this->title = $title;
$this->config = $config;
+ $this->error = FALSE;
$this->response = new stdClass();
// Make our query and possibly fetch the data
$this->query = BugzillaQuery::create($config['type'], $options, $title);
-
- //error_log($this->query);
- //error_log($this->query->id());
- //error_log(print_r($this->query->data, true));
-
+ // Bubble up any query errors
+ if( $this->query->error ) {
+ $this->error = $this->query->error;
+ }
}
- protected function _render_error() {
- $what = (!empty($this->error)) ? $this->error : 'Unknown Error';
- return "<div class='bugzilla error'>Bugzilla Error: $what</div>";
+ protected function _render_error($error) {
+ $this->template = dirname(__FILE__) . '/templates/error.tpl';
+ ob_start(); // Start output buffering.
+ require($this->template);
+ return ob_get_clean();
}
public function render() {
- global $wgBugzillaURL;
+
// Get our template path
$this->template = dirname(__FILE__) . '/templates/' .
$this->config['type'] . '/' .
$this->config['display'] . '.tpl';
- //error_log($this->template);
-
// Make sure a template is there
if( !file_exists($this->template) ) {
$this->error = 'Invalid type and display combination';
}
+ // If there are any errors (either from the template path above or
+ // elsewhere) output them
+ if( $this->error ) {
+ return $this->_render_error($this->error);
+ }
+
$this->_setup_template_data();
$response = $this->response;
View
7 templates/error.tpl
@@ -0,0 +1,7 @@
+<!-- Structure mimics existing mediawiki error boxes -->
+<div class="bugzilla errorbox">
+ <h2>Bugzilla query error</h2>
+ <p>
+ <?php echo $error; ?>
+ </p>
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.