From c4e1458b1ddb3fbcdbf74815a270774b4e97adba Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 17 Jun 2015 12:26:50 +0200 Subject: [PATCH] Providing a more meaningful error message when attempting to open serial monitor and linux user misses permission on device. Fixes #2100 --- arduino-core/src/processing/app/Serial.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arduino-core/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java index 53d0601ae..0230cdb74 100644 --- a/arduino-core/src/processing/app/Serial.java +++ b/arduino-core/src/processing/app/Serial.java @@ -123,7 +123,10 @@ public class Serial implements SerialPortEventListener { port.openPort(); port.setParams(rate, databits, stopbits, parity, true, true); port.addEventListener(this); - } catch (Exception e) { + } catch (SerialPortException e) { + if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) { + throw new SerialException(I18n.format(_("Error opening serial port ''{0}''. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission"), iname)); + } throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e); }