Skip to content

Commit 08a68d4

Browse files
committed
Throwing GraphQL\Error\Error vs GraphQL\Error\UserError from type definitions
1 parent e6e531b commit 08a68d4

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/Type/Definition/FloatType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
namespace GraphQL\Type\Definition;
33

4+
use GraphQL\Error\Error;
45
use GraphQL\Error\InvariantViolation;
5-
use GraphQL\Error\UserError;
66
use GraphQL\Language\AST\FloatValueNode;
77
use GraphQL\Language\AST\IntValueNode;
88
use GraphQL\Utils\Utils;
@@ -63,7 +63,7 @@ private function coerceFloat($value, $isInput)
6363
$isInput ? Utils::printSafeJson($value) : Utils::printSafe($value)
6464
);
6565
}
66-
throw ($isInput ? new UserError($err) : new InvariantViolation($err));
66+
throw ($isInput ? new Error($err) : new InvariantViolation($err));
6767
}
6868

6969
/**

src/Type/Definition/IDType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
namespace GraphQL\Type\Definition;
33

4+
use GraphQL\Error\Error;
45
use GraphQL\Error\InvariantViolation;
5-
use GraphQL\Error\UserError;
66
use GraphQL\Language\AST\IntValueNode;
77
use GraphQL\Language\AST\StringValueNode;
88
use GraphQL\Utils\Utils;
@@ -65,7 +65,7 @@ public function parseValue($value)
6565
return 'null';
6666
}
6767
if (!is_scalar($value)) {
68-
throw new UserError("ID type cannot represent non scalar value: " . Utils::printSafeJson($value));
68+
throw new Error("ID type cannot represent non scalar value: " . Utils::printSafeJson($value));
6969
}
7070
return (string) $value;
7171
}

src/Type/Definition/IntType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
namespace GraphQL\Type\Definition;
33

4+
use GraphQL\Error\Error;
45
use GraphQL\Error\InvariantViolation;
5-
use GraphQL\Error\UserError;
66
use GraphQL\Language\AST\IntValueNode;
77
use GraphQL\Utils\Utils;
88

@@ -57,7 +57,7 @@ public function parseValue($value)
5757
*/
5858
private function coerceInt($value, $isInput)
5959
{
60-
$errClass = $isInput ? UserError::class : InvariantViolation::class;
60+
$errClass = $isInput ? Error::class : InvariantViolation::class;
6161

6262
if ($value === '') {
6363
throw new $errClass(

src/Type/Definition/ObjectType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace GraphQL\Type\Definition;
3+
use GraphQL\Error\Error;
34
use GraphQL\Error\InvariantViolation;
4-
use GraphQL\Error\UserError;
55
use GraphQL\Utils\Utils;
66

77

@@ -133,7 +133,7 @@ public function getField($name)
133133
$this->getFields();
134134
}
135135
if (!isset($this->fields[$name])) {
136-
throw new UserError(sprintf("Field '%s' is not defined for type '%s'", $name, $this->name));
136+
throw new Error(sprintf("Field '%s' is not defined for type '%s'", $name, $this->name));
137137
}
138138
return $this->fields[$name];
139139
}

src/Type/Definition/StringType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
namespace GraphQL\Type\Definition;
33

4+
use GraphQL\Error\Error;
45
use GraphQL\Error\InvariantViolation;
5-
use GraphQL\Error\UserError;
66
use GraphQL\Language\AST\StringValueNode;
77
use GraphQL\Utils\Utils;
88

@@ -62,7 +62,7 @@ public function parseValue($value)
6262
return 'null';
6363
}
6464
if (!is_scalar($value)) {
65-
throw new UserError("String cannot represent non scalar value: " . Utils::printSafe($value));
65+
throw new Error("String cannot represent non scalar value: " . Utils::printSafe($value));
6666
}
6767
return (string) $value;
6868
}

0 commit comments

Comments
 (0)