From eba8f4f5b6d37bd4066859ac0e078e21137ef069 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Sat, 13 Dec 2014 20:06:31 +0430 Subject: [PATCH] Added some error types --- serial/serial.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/serial/serial.go b/serial/serial.go index 7a1f470..913fe9b 100644 --- a/serial/serial.go +++ b/serial/serial.go @@ -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 }