PluginProbe
Depicter — Popup & Slider Builder / 1.2.0
Depicter — Popup & Slider Builder v1.2.0
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Utility / Http.php

Http.php in Depicter — Popup & Slider Builder 1.2.0, at app/src/Utility/Http.php

38 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Utility;
3
4 class Http {
5
6 public static function getErrorExceptionResponse( \Exception $exception ){
7 $isConnectionError = method_exists( $exception, 'getHandlerContext' );
8 $errorClassInstance = get_class( $exception );
9
10 $error = [
11 'message' => $exception->getMessage(),
12 'detail' => $exception->getMessage(),
13 'errCode' => $exception->getCode(),
14 'group' => 'Exception', // name of exception group
15 'type' => basename( str_replace('\\', '/', $errorClassInstance )), // unqualified (short) exception class name
16 'instance' => $errorClassInstance,
17 'context' => null,
18 'statusCode' => 500
19 ];
20
21 if( $isConnectionError ){
22 $error['message'] = __( 'Connection Error ..', 'depicter' );
23 $error['group'] = 'RequestException';
24 $error['context'] = $exception->getHandlerContext();
25 $error['statusCode'] = 503;
26 }
27
28 if( ! empty( $error['context']['error'] ) ){
29 $error['detail'] = $error['context']['error'];
30 }
31 if( ! empty( $error['context']['errno'] ) ){
32 $error['errCode'] = $error['context']['errno'];
33 }
34
35 return $error;
36 }
37 }
38