Skip to content

Instantly share code, notes, and snippets.

@Spomky
Last active September 2, 2016 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spomky/cfe8d510548e16fe3f9bf3c6b0b372ff to your computer and use it in GitHub Desktop.
Save Spomky/cfe8d510548e16fe3f9bf3c6b0b372ff to your computer and use it in GitHub Desktop.
Proposition
<?php
namespace Lexik\Bundle\JWTAuthenticationBundle\Exception;
/**
* Base class for exceptions thrown during JWTEncoderInterface::encode().
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class JWTEncodeFailureException extends JWTFailureException
{
const INVALID_KEY = 'invalid_key';
const UNSIGNED_JWS = 'unsigned_jws';
}
<?php
namespace Lexik\Bundle\JWTAuthenticationBundle\Exception;
/**
* Base class for exceptions thrown during JWTEncoderInterface::decode().
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class JWTDecodeFailureException extends JWTFailureException
{
const INVALID_JWT = 'invalid_jwt';
const UNVERIFIED_JWS = 'unverified_jws';
const EXPIRED_JWT = 'expired_jwt';
}
<?php
namespace Lexik\Bundle\JWTAuthenticationBundle\Exception;
/**
* Base class for exceptions thrown during JWT creation/loading.
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class JWTFailureException extends \Exception
{
/**
* @var string
*/
private $reason;
/**
* @param string $message
* @param string $reason
* @param \Exception|null $previous
*/
public function __construct($message, $reason, \Exception $previous = null)
{
parent::__construct($message, 0, $previous);
}
/**
* @return string
*/
public function getReason()
{
return $this->reason;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment