Completed
Push — master ( 750008...8278b6 )
by Christoffer
02:27 queued 19s
created

formatError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Error;
4
5
use function Digia\GraphQL\Util\invariant;
6
7
/**
8
 * @param GraphQLException $error
9
 * @return array
10
 * @throws InvariantException
11
 */
12
function formatError(GraphQLException $error): array
13
{
14
    invariant(null !== $error, 'Received null error.');
15
16
    return array_merge($error->getExtensions() ?? [], [
17
        'message'   => $error->getMessage(),
18
        'locations' => $error->getLocationsAsArray(),
19
        'path'      => $error->getPath(),
20
    ]);
21
}
22