49 'message' => $msg->getKey(),
50 'params' => $msg->getParams(),
51 'code' => $msg->getApiCode(),
65 'code' => $msg->getApiCode(),
66 'info' => $msg->text(),
67 ] + $msg->getApiData();
79 $ret = parent::formatException( $exception, $options );
80 return empty( $options[
'bc'] ) ? $ret : $ret[
'info'];
87 if ( $tag ===
'error' ) {
89 $existingError = $this->result->getResultData( [
'error' ] );
90 if ( !is_array( $existingError ) ||
91 !isset( $existingError[
'code'] ) || !isset( $existingError[
'info'] )
94 'code' => $msg->getApiCode(),
96 ] + $msg->getApiData();
97 $this->result->addValue(
null,
'error', $value,
101 if ( $modulePath ===
null ) {
102 $moduleName =
'unknown';
104 $i = strrpos( $modulePath,
'+' );
105 $moduleName = $i ===
false ? $modulePath : substr( $modulePath, $i + 1 );
110 $path = [ $tag, $moduleName ];
111 $oldWarning = $this->result->getResultData( [ $tag, $moduleName, $tag ] );
112 if ( $oldWarning !==
null ) {
113 $warnPos = strpos( $oldWarning, $value );
115 if ( $warnPos !==
false && ( $warnPos === 0 || $oldWarning[$warnPos - 1] ===
"\n" ) ) {
117 $warnPos += strlen( $value );
118 if ( strlen( $oldWarning ) <= $warnPos || $oldWarning[$warnPos] ===
"\n" ) {
123 $value =
"$oldWarning\n$value";
125 $this->result->addContentValue(
$path, $tag, $value,
132class_alias( ApiErrorFormatter_BackCompat::class,
'ApiErrorFormatter_BackCompat' );
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getMessages(?string $type=null)
Returns a list of error messages, optionally only those of the given type.
isGood()
Returns whether the operation completed and didn't have any error or warnings.