Skip to content

Commit 49ae080

Browse files
committed
Fix bug
1 parent 9285299 commit 49ae080

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

model/startup/startup.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
class VF_ModelStartupStartup extends VF_Model
44
{
5-
public function getVF_Resolvers() {
5+
public function getVF_Resolvers()
6+
{
67
$rawMapping = file_get_contents(VF_DIR_PLUGIN.'mapping.json');
7-
$mapping = json_decode( $rawMapping, true );
8+
$mapping = json_decode($rawMapping, true);
89
$result = array();
910
foreach ($mapping as $key => $value) {
1011
$that = $this;
11-
$result[$key] = function($root, $args, $context) use ($value, $that) {
12-
return $that->load->resolver($value, $args);
12+
$result[$key] = function ($root, $args, $context) use ($value, $that) {
13+
try {
14+
return $that->load->resolver($value, $args);
15+
} catch (Exception $e) {
16+
throw new MySafeException($e->getMessage());
17+
}
1318
};
1419
}
1520

1621
return $result;
1722
}
18-
}
23+
}

system/helpers/MySafeException.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* 2019 (c) VueFront
4+
*
5+
* MODULE VueFront
6+
*
7+
* @author VueFront
8+
* @copyright Copyright (c) permanent, VueFront
9+
* @license MIT
10+
* @version 0.1.0
11+
*/
12+
13+
use GraphQL\Error\ClientAware;
14+
15+
class VF_MySafeException extends \Exception implements ClientAware
16+
{
17+
public function isClientSafe()
18+
{
19+
return true;
20+
}
21+
22+
public function getCategory()
23+
{
24+
return 'businessLogic';
25+
}
26+
}

system/startup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require_once(VF_DIR_PLUGIN . 'system/engine/model.php');
99
require_once(VF_DIR_PLUGIN . 'system/engine/registry.php');
1010
require_once(VF_DIR_PLUGIN . 'system/engine/proxy.php');
11+
require_once(VF_DIR_PLUGIN . 'system/helpers/MySafeException.php');
1112

1213
function VF_Start(WP_REST_Request $request = null) {
1314
$registry = new VF_Registry();

0 commit comments

Comments
 (0)