aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Rest/ResponseFactory.php
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2019-06-12 15:51:59 -0400
committerBrad Jorsch <bjorsch@wikimedia.org>2019-09-04 10:12:35 -0400
commitebfbd2d42a57e6cf87feda0d46b0c1bd2c00c2c5 (patch)
tree78fcbc55641d99594b9d8729597cc3bea3ceeee9 /includes/Rest/ResponseFactory.php
parentbb575f1dc75af99de11568837cdabe28dde5b8e5 (diff)
downloadmediawikicore-ebfbd2d42a57e6cf87feda0d46b0c1bd2c00c2c5.tar.gz
mediawikicore-ebfbd2d42a57e6cf87feda0d46b0c1bd2c00c2c5.zip
rest: Use ParamValidator library, add BodyValidator
Parameter validation is based on parameter definitions like those in the Action API, using the new ParamValidator library. Handlers should use the provided Handler methods to access parameters rather than fetching them directly from the RequestInterface. Body validation allows the handler to have the (non-form-data) body of a request parsed and validated. The only validator included in this patch ignores the body entirely; future patches may implement validation for JSON bodies based on JSON schemas, or the like. Bug: T223239 Change-Id: I3c37ea2b432840514b6bff90007c8403989225d5
Diffstat (limited to 'includes/Rest/ResponseFactory.php')
-rw-r--r--includes/Rest/ResponseFactory.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/includes/Rest/ResponseFactory.php b/includes/Rest/ResponseFactory.php
index d18cdb5d6bbe..5e5a19852d8a 100644
--- a/includes/Rest/ResponseFactory.php
+++ b/includes/Rest/ResponseFactory.php
@@ -175,8 +175,13 @@ class ResponseFactory {
public function createFromException( $exception ) {
if ( $exception instanceof HttpException ) {
// FIXME can HttpException represent 2xx or 3xx responses?
- $response = $this->createHttpError( $exception->getCode(),
- [ 'message' => $exception->getMessage() ] );
+ $response = $this->createHttpError(
+ $exception->getCode(),
+ array_merge(
+ [ 'message' => $exception->getMessage() ],
+ (array)$exception->getErrorData()
+ )
+ );
} else {
$response = $this->createHttpError( 500, [
'message' => 'Error: exception of type ' . get_class( $exception ),