1 module jwt.exceptions; 2 3 /** 4 * thrown when there are issues with token verification 5 */ 6 class VerifyException : Exception { 7 this(string s) { 8 super(s); 9 } 10 } 11 12 /** 13 * thrown when attempting to encode or decode a token with an unsupported algorithm 14 */ 15 class UnsupportedAlgorithmException : Exception { 16 this(string s) { 17 super(s); 18 } 19 } 20 21 /** 22 * thrown when there are issues with the token 23 */ 24 class InvalidTokenException : VerifyException { 25 this(string s) { 26 super(s); 27 } 28 } 29 30 /** 31 * thrown when the tokens signature doesn't match the data signature 32 */ 33 class InvalidSignatureException : VerifyException { 34 this(string s) { 35 super(s); 36 } 37 } 38 39 /** 40 * thrown when the algorithm used to sign the token is invalid 41 */ 42 class InvalidAlgorithmException : VerifyException { 43 this(string s) { 44 super(s); 45 } 46 } 47 48 /** 49 * thrown when the tokens is expired 50 */ 51 class ExpiredException : VerifyException { 52 this(string s) { 53 super(s); 54 } 55 } 56 57 /** 58 * thrown when the token is not valid yet 59 * or in other words when the nbf claim time is before the current time 60 */ 61 class NotBeforeException : VerifyException { 62 this(string s) { 63 super(s); 64 } 65 } 66 67 /** 68 * thrown when the token has an incorrect format 69 */ 70 class MalformedToken : InvalidTokenException { 71 this(string s) { 72 super(s); 73 } 74 } 75 76 /** 77 * thrown when the tokens will expire before it becomes valid 78 * usually when the nbf claim is greater than the exp claim 79 */ 80 class ExpiresBeforeValidException : Exception { 81 this(string s) { 82 super(s); 83 } 84 }