github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/network/node/errors.go (about) 1 package node 2 3 import ( 4 "errors" 5 "fmt" 6 "reflect" 7 "syscall" 8 ) 9 10 var ( 11 ErrDatadirUsed = errors.New("datadir already used by another process") 12 ErrNodeStopped = errors.New("node not started") 13 ErrNodeRunning = errors.New("node already running") 14 ErrServiceUnknown = errors.New("unknown service") 15 16 datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true} 17 ) 18 19 func convertFileLockError(err error) error { 20 if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] { 21 return ErrDatadirUsed 22 } 23 return err 24 } 25 26 type DuplicateServiceError struct { 27 Kind reflect.Type 28 } 29 30 func (e *DuplicateServiceError) Error() string { 31 return fmt.Sprintf("duplicate service: %v", e.Kind) 32 } 33 34 type StopError struct { 35 Server error 36 Services map[reflect.Type]error 37 } 38 39 func (e *StopError) Error() string { 40 return fmt.Sprintf("server: %v, services: %v", e.Server, e.Services) 41 }