13trait RestStatusTrait {
24 private function throwExceptionForStatus(
30 $data += [
'error-keys' => $this->getStatusErrorKeys( $status ) ];
32 if ( is_string( $msg ) ) {
33 $msg = MessageValue::new( $msg )
37 throw new LocalizedHttpException( $msg, $code, $data );
40 private function getStatusErrorKeys(
StatusValue $status ) {
44 $keys[] = $msg->getKey();
47 return array_unique( $keys );
50 private function logStatusError(
StatusValue $status,
string $message,
string $channel ) {
51 LoggerFactory::getInstance( $channel )->error(
53 [
'reason' => $this->getStatusErrorKeys( $status ) ]
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.