github.com/dylandreimerink/gobpfld@v0.6.1-0.20220205171531-e79c330ad608/internal/syscall/syscall.go (about) 1 package syscall 2 3 import ( 4 "fmt" 5 6 "golang.org/x/sys/unix" 7 ) 8 9 // ENOTSUPP - Operation is not supported 10 const ENOTSUPP = unix.Errno(524) 11 12 // a map of string translations for syscall errors which are no included in the standard library 13 var nonStdErrors = map[unix.Errno]string{ 14 ENOTSUPP: "Operation is not supported", 15 } 16 17 // Error is an error wrapper for syscall errors 18 type Error struct { 19 // Context specific error information since the same code can have different 20 // meaning depending on context 21 Err string 22 // The underlaying syscall error number 23 Errno unix.Errno 24 } 25 26 func (e *Error) Error() string { 27 errStr := nonStdErrors[e.Errno] 28 if errStr == "" { 29 errStr = e.Errno.Error() 30 } 31 32 if e.Err == "" { 33 return fmt.Sprintf("%s (%d)", errStr, e.Errno) 34 } 35 36 return fmt.Sprintf("%s (%s)(%d)", e.Err, errStr, e.Errno) 37 }