Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
fix graphql error formater catch the exception throw in app not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingsun committed Dec 19, 2017
1 parent d047725 commit ce50af8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GraphQL\Error\Error;
use GraphQL\FormattedError;
use yii\graphql\exceptions\ValidatorException;
use yii\web\HttpException;

/**
* Class ErrorFormatter
Expand All @@ -21,6 +22,11 @@ public static function formatError(Error $e)
if ($previous instanceof ValidatorException) {
return $previous->formatErrors;
}
if ($previous instanceof HttpException) {
return ['code' => $previous->statusCode, 'message' => $previous->getMessage()];
} else {
return ['code' => $previous->getCode(), 'message' => $previous->getMessage()];
}
} else {
Yii::error($e->getMessage(), get_class($e));
}
Expand Down

0 comments on commit ce50af8

Please sign in to comment.