Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ResponseException
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getResponse
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Rest;
4
5/**
6 * This is an exception class that wraps a Response and extends
7 * HttpException.  It is used when a particular response type
8 * (whatever the HTTP status code) is treated as an exceptional output
9 * in your API, and you want to be able to throw it from wherever you
10 * are and immediately halt request processing.  It can also be used
11 * to customize the standard 3xx or 4xx error Responses returned by
12 * the standard HttpException, for example to add custom headers.
13 *
14 * @newable
15 * @since 1.36
16 */
17class ResponseException extends HttpException {
18
19    /**
20     * The wrapped Response.
21     * @var Response
22     */
23    private $response;
24
25    /**
26     * @stable to call
27     *
28     * @param Response $response The wrapped Response
29     */
30    public function __construct( Response $response ) {
31        parent::__construct( 'Response', $response->getStatusCode() );
32        $this->response = $response;
33    }
34
35    /**
36     * @return Response
37     */
38    public function getResponse(): Response {
39        return $this->response;
40    }
41}