-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Force low-level errors to throw in dev to prevent errors leaking…
… into JSON response
- Loading branch information
Aaron Carlino
committed
Jul 26, 2021
1 parent
ed27d96
commit 410e405
Showing
6 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
|
||
namespace SilverStripe\GraphQL\QueryHandler; | ||
|
||
/** | ||
* Throws everything, including notices, so the JSON response doesn't get corruped by E_NOTICE, E_WARN | ||
* outputs. | ||
*/ | ||
class DevErrorHandler | ||
{ | ||
/** | ||
* @param $severity | ||
* @param $message | ||
* @param $filename | ||
* @param $line | ||
* @return false | ||
* @throws QueryException | ||
*/ | ||
public static function handleError($severity, $message, $filename, $line) | ||
{ | ||
if (!(error_reporting() & $severity)) { | ||
return false; | ||
} | ||
|
||
$errstr = htmlspecialchars($errstr); | ||
|
||
throw new QueryException($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
|
||
namespace SilverStripe\GraphQL\QueryHandler; | ||
|
||
use Exception; | ||
|
||
class QueryException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters