From b76f4769bdc076d209c862db24b9255e828c7169 Mon Sep 17 00:00:00 2001 From: acoshift Date: Wed, 23 May 2018 20:46:57 +0700 Subject: [PATCH] add IsInvalidTextRepresentation --- error.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/error.go b/error.go index c983490..264e35b 100644 --- a/error.go +++ b/error.go @@ -13,7 +13,7 @@ func contains(xs []string, x string) bool { return false } -// IsUniqueViolation checks is error unique_violation with given constraint, +// IsUniqueViolation checks is error an unique_violation with given constraint, // constraint can be empty to ignore constraint name checks func IsUniqueViolation(err error, constraint ...string) bool { if pqErr, ok := err.(*pq.Error); ok && pqErr.Code == "23505" { @@ -24,3 +24,11 @@ func IsUniqueViolation(err error, constraint ...string) bool { } return false } + +// IsInvalidTextRepresentation checks is error an invalid_text_representation +func IsInvalidTextRepresentation(err error) bool { + if pqErr, ok := err.(*pq.Error); ok && pqErr.Code == "22P02" { + return true + } + return false +}