Completed
Push — master ( 150a3d...219536 )
by
unknown
04:07
created

JSONHttpError::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Bernhard Posselt <[email protected]>
9
 * @copyright Bernhard Posselt 2014
10
 */
11
12
namespace OCA\News\Controller;
13
14
use \OCP\AppFramework\Http\JSONResponse;
15
16
17
trait JSONHttpError {
18
19
20
    /**
21
     * @param \Exception $exception the message that is returned taken from the
22
     * exception
23
     * @param int $code the http error code
24
     * @return \OCP\AppFramework\Http\JSONResponse
25
     */
26
    public function error(\Exception $exception, $code) {
27
        return new JSONResponse(['message' => $exception->getMessage()], $code);
28
    }
29
30
31
}