mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-28 07:50:24 +00:00
e64049c30b
Introduce a clear distinction between internal exceptions and user-visible exceptions, leaving AFPException as base abstract class. Later, it should be possible to narrow some types around, e.g. in ParserStatus (that might work with user-visible exceptions only). Also a future TODO is putting all the exceptions in their own namespace (probably ...\Parser\Exception). Change-Id: I4e33a45117f0a3e73af03cc1e3f2734beaf2b5e1
31 lines
546 B
PHP
31 lines
546 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Parser;
|
|
|
|
use MWException;
|
|
|
|
abstract class AFPException extends MWException {
|
|
|
|
/**
|
|
* Serialize data for edit stash
|
|
* @return array
|
|
*/
|
|
public function toArray() : array {
|
|
return [
|
|
'class' => static::class,
|
|
'message' => $this->getMessage(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Deserialize data from edit stash
|
|
* @param array $value
|
|
* @return static
|
|
*/
|
|
public static function fromArray( array $value ) {
|
|
[ 'class' => $cls, 'message' => $message ] = $value;
|
|
return new $cls( $message );
|
|
}
|
|
|
|
}
|