Vendor
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use Illuminate\Auth\AuthenticationException as IlluminateAuthenticationException;
|
||||
|
||||
class AuthenticationException extends IlluminateAuthenticationException implements RendersErrorsExtensions
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return 'authentication';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content that is put in the "extensions" part
|
||||
* of the returned error.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extensionsContent(): array
|
||||
{
|
||||
return ['guards' => $this->guards];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use GraphQL\Error\ClientAware;
|
||||
use Illuminate\Auth\Access\AuthorizationException as IlluminateAuthorizationException;
|
||||
|
||||
class AuthorizationException extends IlluminateAuthorizationException implements ClientAware
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const CATEGORY = 'authorization';
|
||||
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return self::CATEGORY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GraphQL\Error\ClientAware;
|
||||
|
||||
class DefinitionException extends Exception implements ClientAware
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return 'schema';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GraphQL\Error\ClientAware;
|
||||
|
||||
class DirectiveException extends Exception implements ClientAware
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return 'schema';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
|
||||
class GenericException extends Error
|
||||
{
|
||||
/**
|
||||
* The category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $category = 'generic';
|
||||
|
||||
/**
|
||||
* Set the contents that will be rendered under the "extensions" key of the error response.
|
||||
*
|
||||
* @param mixed $extensions
|
||||
* @return $this
|
||||
*/
|
||||
public function setExtensions($extensions): self
|
||||
{
|
||||
$this->extensions = (array) $extensions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the category that will be rendered under the "extensions" key of the error response.
|
||||
*
|
||||
* @param string $category
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategory(string $category): self
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidDriverException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GraphQL\Error\ClientAware;
|
||||
|
||||
class ParseException extends Exception implements ClientAware
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return 'schema';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use GraphQL\Error\ClientAware;
|
||||
|
||||
/**
|
||||
* Exceptions may implement this interface.
|
||||
*
|
||||
* This enables them to render additional content to the errors
|
||||
* entry that is returned to the client when it occurs.
|
||||
*/
|
||||
interface RendersErrorsExtensions extends ClientAware
|
||||
{
|
||||
/**
|
||||
* Return the content that is put in the "extensions" part
|
||||
* of the returned error.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extensionsContent(): array;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use GraphQL\Error\ClientAware;
|
||||
|
||||
class SubscriptionException extends InvalidArgumentException implements ClientAware
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return 'subscription';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Nuwave\Lighthouse\Exceptions;
|
||||
|
||||
class ValidationException extends \Illuminate\Validation\ValidationException implements RendersErrorsExtensions
|
||||
{
|
||||
/**
|
||||
* Returns true when exception message is safe to be displayed to a client.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClientSafe()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string describing a category of the error.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return 'validation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content that is put in the "extensions" part
|
||||
* of the returned error.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extensionsContent(): array
|
||||
{
|
||||
return ['validation' => $this->errors()];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user