forked from FortnoxAB/goclamd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.go
More file actions
33 lines (28 loc) · 679 Bytes
/
Copy patherror.go
File metadata and controls
33 lines (28 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package goclamd
import "fmt"
// VirusFoundError is a custom error where we can get the virus name from Virus() method
type VirusFoundError struct {
virus string
res string
}
func NewVirusFoundError(res []byte, virus []byte) error {
return &VirusFoundError{
res: string(res),
virus: string(virus),
}
}
func (vfe *VirusFoundError) Error() string {
return fmt.Sprintf("%s: %s", vfe.Resolution(), vfe.Virus())
}
func (vfe *VirusFoundError) Virus() string {
return vfe.virus
}
func (vfe *VirusFoundError) Resolution() string {
return vfe.res
}
func IsVirusErr(err error) *VirusFoundError {
if vfe, ok := err.(*VirusFoundError); ok {
return vfe
}
return nil
}