Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -257,6 +257,11 @@ |
258 | 258 | try { |
259 | 259 | $this->executeAction(); |
260 | 260 | } catch (Exception $e) { |
| 261 | + // Log it |
| 262 | + if ( $e instanceof MWException ) { |
| 263 | + wfDebugLog( 'exception', $e->getLogMessage() ); |
| 264 | + } |
| 265 | + |
261 | 266 | // |
262 | 267 | // Handle any kind of exception by outputing properly formatted error message. |
263 | 268 | // If this fails, an unhandled exception should be thrown so that global error |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -129,7 +129,16 @@ |
130 | 130 | $file = $this->getFile(); |
131 | 131 | $line = $this->getLine(); |
132 | 132 | $message = $this->getMessage(); |
133 | | - return $wgRequest->getRequestURL() . " Exception from line $line of $file: $message"; |
| 133 | + if ( isset( $wgRequest ) ) { |
| 134 | + $url = $wgRequest->getRequestURL(); |
| 135 | + if ( !$url ) { |
| 136 | + $url = '[no URL]'; |
| 137 | + } |
| 138 | + } else { |
| 139 | + $url = '[no req]'; |
| 140 | + } |
| 141 | + |
| 142 | + return "$url Exception from line $line of $file: $message"; |
134 | 143 | } |
135 | 144 | |
136 | 145 | /** Output the exception report using HTML */ |