=== Action API changes in 1.33 ===
* (T198913) Added 'ApiOptions' hook.
* The JSON formatversion=2 is no longer experimental.
+* Internal API errors (those with code beginning "internal_api_error") will
+ include the exception class name in a data field named "errorclass".
+ * Class names are not guaranteed to remain stable, and in particular database
+ exceptions will now include the "Wikimedia\Rdbms\" prefix in the class name.
+ * The code including an exception class name is deprecated. In the future,
+ all internal errors will use code "internal_api_error".
* …
=== Action API internal changes in 1.33 ===
if ( !isset( $options['code'] ) ) {
$class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $exception ) );
$options['code'] = 'internal_api_error_' . $class;
+ $options['data']['errorclass'] = get_class( $exception );
}
}
$params = [ wfEscapeWikiText( $exception->getMessage() ) ];
// TODO: Avoid embedding arbitrary class names in the error code.
$class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $e ) );
$code = 'internal_api_error_' . $class;
+ $data = [ 'errorclass' => get_class( $e ) ];
if ( $config->get( 'ShowExceptionDetails' ) ) {
if ( $e instanceof ILocalizedException ) {
$msg = $e->getMessageObject();
$params = [ 'apierror-exceptioncaughttype', WebRequest::getRequestId(), get_class( $e ) ];
}
- $messages[] = ApiMessage::create( $params, $code );
+ $messages[] = ApiMessage::create( $params, $code, $data );
}
return $messages;
}
[
'text' => '<b>Something broke!</b>',
'code' => 'internal_api_error_RuntimeException',
- 'data' => [],
+ 'data' => [
+ 'errorclass' => 'RuntimeException',
+ ],
]
],
'Normal exception, wrapped' => [
<?php
+use Wikimedia\Rdbms\DBQueryError;
use Wikimedia\TestingAccessWrapper;
/**
[
'code' => 'internal_api_error_InvalidArgumentException',
'text' => "[$reqId] Exception caught: Random exception",
+ 'data' => [
+ 'errorclass' => InvalidArgumentException::class,
+ ],
]
],
'trace' => $trace,
'code' => 'internal_api_error_DBQueryError',
'text' => "[$reqId] Exception caught: A database query error has occurred. " .
"This may indicate a bug in the software.",
+ 'data' => [
+ 'errorclass' => DBQueryError::class,
+ ],
]
],
'trace' => $dbtrace,
[
'code' => 'internal_api_error_MediaWiki\ShellDisabledError',
'text' => "[$reqId] Exception caught: " . $nsex->getMessage(),
+ 'data' => [
+ 'errorclass' => MediaWiki\ShellDisabledError::class,
+ ],
]
],
'trace' => $nstrace,