-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created custom error handler; Applied default error handling functionality
- Loading branch information
Maksym Novik
committed
Feb 7, 2019
1 parent
8dfe26a
commit 583ff11
Showing
4 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
29 changes: 29 additions & 0 deletions
29
lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php
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,29 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\GraphQl\Query; | ||
|
||
/** | ||
* Class ErrorHandler | ||
* | ||
* @package Magento\Framework\GraphQl\Query | ||
*/ | ||
class ErrorHandler implements ErrorHandlerInterface | ||
{ | ||
/** | ||
* Handle errors | ||
* | ||
* @param \GraphQL\Error\Error[] $errors | ||
* @param callable $formatter | ||
* | ||
* @return array | ||
*/ | ||
public function handle(array $errors, callable $formatter):array | ||
{ | ||
return array_map($formatter, $errors); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
lib/internal/Magento/Framework/GraphQl/Query/ErrorHandlerInterface.php
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,26 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\GraphQl\Query; | ||
|
||
/** | ||
* Interface ErrorHandlerInterface | ||
* | ||
* @package Magento\Framework\GraphQl\Query | ||
*/ | ||
interface ErrorHandlerInterface | ||
{ | ||
/** | ||
* Handle errors | ||
* | ||
* @param \GraphQL\Error\Error[] $errors | ||
* @param callable $formatter | ||
* | ||
* @return array | ||
*/ | ||
public function handle(array $errors, callable $formatter):array; | ||
} |
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