+try {
+ wfRunHooks( 'ApiBeforeMain', array( &$processor ) );
+ if ( !$processor instanceof ApiMain ) {
+ throw new MWException( 'ApiBeforMain hook set $processor to a non-ApiMain class' );
+ }
+} catch ( Exception $e ) {
+ // Crap. Try to report the exception in API format to be friendly to clients.
+ ApiMain::handleApiBeforeMainException( $e );
+ $processor = false;
+}