61 'message' => $msg->getKey(),
62 'params' => $msg->getParams(),
63 'code' => $msg->getApiCode(),
76 'code' => $msg->getApiCode(),
77 'info' => $msg->text(),
78 ] + $msg->getApiData();
90 $ret = parent::formatException( $exception, $options );
91 return empty( $options[
'bc'] ) ? $ret : $ret[
'info'];
97 if ( $tag ===
'error' ) {
99 $existingError = $this->result->getResultData( [
'error' ] );
100 if ( !is_array( $existingError ) ||
101 !isset( $existingError[
'code'] ) || !isset( $existingError[
'info'] )
104 'code' => $msg->getApiCode(),
106 ] + $msg->getApiData();
107 $this->result->addValue(
null,
'error', $value,
111 if ( $modulePath ===
null ) {
112 $moduleName =
'unknown';
114 $i = strrpos( $modulePath,
'+' );
115 $moduleName = $i ===
false ? $modulePath : substr( $modulePath, $i + 1 );
120 $path = [ $tag, $moduleName ];
121 $oldWarning = $this->result->getResultData( [ $tag, $moduleName, $tag ] );
122 if ( $oldWarning !==
null ) {
123 $warnPos = strpos( $oldWarning, $value );
125 if ( $warnPos !==
false && ( $warnPos === 0 || $oldWarning[$warnPos - 1] ===
"\n" ) ) {
127 $warnPos += strlen( $value );
128 if ( strlen( $oldWarning ) <= $warnPos || $oldWarning[$warnPos] ===
"\n" ) {
133 $value =
"$oldWarning\n$value";
135 $this->result->addContentValue(
$path, $tag, $value,
142class_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.