From 96fef824970c561c9ded281e9789ce907be05d56 Mon Sep 17 00:00:00 2001 From: "John.Lockwood" Date: Mon, 25 Apr 2016 11:34:10 -0700 Subject: [PATCH] Include expire delta in error message --- parser.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parser.go b/parser.go index a1accc2..fbde9cb 100644 --- a/parser.go +++ b/parser.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "strings" + "time" ) type Parser struct { @@ -113,7 +114,8 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { } if vexp && now > exp { - vErr.Inner = fmt.Errorf("token is expired") + delta := time.Unix(now, 0).Sub(time.Unix(exp, 0)) + vErr.Inner = fmt.Errorf("token is expired by %v", delta) vErr.Errors |= ValidationErrorExpired }