Added some error types
This commit is contained in:
@@ -21,10 +21,11 @@ type SerialPortError struct {
|
||||
|
||||
const (
|
||||
ERROR_PORT_BUSY = 1
|
||||
ERROR_NOT_FOUND = 2
|
||||
ERROR_PORT_NOT_FOUND = 2
|
||||
ERROR_INVALID_SERIAL_PORT = 3
|
||||
ERROR_PERMISSION_DENIED = 4
|
||||
ERROR_INVALID_PORT_SPEED = 5
|
||||
ERROR_ENUMERATING_PORTS = 6
|
||||
ERROR_OTHER = 99
|
||||
)
|
||||
|
||||
@@ -32,7 +33,7 @@ func (e SerialPortError) Error() string {
|
||||
switch e.code {
|
||||
case ERROR_PORT_BUSY:
|
||||
return "Serial port busy"
|
||||
case ERROR_NOT_FOUND:
|
||||
case ERROR_PORT_NOT_FOUND:
|
||||
return "Serial port not found"
|
||||
case ERROR_INVALID_SERIAL_PORT:
|
||||
return "Invalid serial port"
|
||||
@@ -40,6 +41,8 @@ func (e SerialPortError) Error() string {
|
||||
return "Permission denied"
|
||||
case ERROR_INVALID_PORT_SPEED:
|
||||
return "Invalid port speed"
|
||||
case ERROR_ENUMERATING_PORTS:
|
||||
return "Could not enumerate serial ports"
|
||||
}
|
||||
return e.err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user