From 809db0b902be025539d2b554dd7ad72e2efea1c3 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Fri, 7 Apr 2023 13:39:35 +0200 Subject: [PATCH] Stringify error messages. --- define.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/define.go b/define.go index 6c67382..e7f8918 100644 --- a/define.go +++ b/define.go @@ -128,8 +128,24 @@ const CL_INIT_DEFAULT C.uint = C.CL_INIT_DEFAULT // Wraps the corresponding error message func Strerr(code ErrorCode) error { - err := errors.New(fmt.Sprintf("Error %d", C.int(code))) - return err + switch code { + case CL_VIRUS: + return errors.New("Virus detected") + case CL_EUNPACK: + return errors.New("Unpacking failed") + case CL_EVERIFY: + return errors.New("Verification failed") + case CL_ECVD: + return errors.New("CVD database error") + case CL_EOPEN: + case CL_EACCES: + case CL_EREAD: + case CL_ESTAT: + return errors.New("I/O error while scanning file.") + default: + return errors.New(fmt.Sprintf("Error %d", C.int(code))) + } + return errors.New("Unknown error") } /* db options */