@@ -1197,9 +1197,14 @@ public void onBoardOrPortChange() {
1197
1197
// Populate importToLibraryTable
1198
1198
importToLibraryTable = new HashMap <String , File >();
1199
1199
for (File subfolder : libraries .values ()) {
1200
- String packages [] = headerListFromIncludePath (subfolder );
1201
- for (String pkg : packages )
1202
- importToLibraryTable .put (pkg , subfolder );
1200
+ try {
1201
+ String packages [] = headerListFromIncludePath (subfolder );
1202
+ for (String pkg : packages ) {
1203
+ importToLibraryTable .put (pkg , subfolder );
1204
+ }
1205
+ } catch (IOException e ) {
1206
+ showWarning (_ ("Error" ), I18n .format ("Unable to list header files in {0}" , subfolder ), e );
1207
+ }
1203
1208
}
1204
1209
1205
1210
// Update editors status bar
@@ -1548,8 +1553,13 @@ protected void addLibraries(JMenu menu, Map<String, File> libs) throws IOExcepti
1548
1553
Collections .sort (list , String .CASE_INSENSITIVE_ORDER );
1549
1554
1550
1555
ActionListener listener = new ActionListener () {
1551
- public void actionPerformed (ActionEvent e ) {
1552
- activeEditor .getSketch ().importLibrary (e .getActionCommand ());
1556
+ public void actionPerformed (ActionEvent event ) {
1557
+ String jarPath = event .getActionCommand ();
1558
+ try {
1559
+ activeEditor .getSketch ().importLibrary (jarPath );
1560
+ } catch (IOException e ) {
1561
+ showWarning (_ ("Error" ), I18n .format ("Unable to list header files in {0}" , jarPath ), e );
1562
+ }
1553
1563
}
1554
1564
};
1555
1565
@@ -1571,8 +1581,12 @@ public void actionPerformed(ActionEvent e) {
1571
1581
* the header files in its sub-folders, as those should be included from
1572
1582
* within the header files at the top-level).
1573
1583
*/
1574
- static public String [] headerListFromIncludePath (File path ) {
1575
- return path .list (new OnlyFilesWithExtension (".h" ));
1584
+ static public String [] headerListFromIncludePath (File path ) throws IOException {
1585
+ String [] list = path .list (new OnlyFilesWithExtension (".h" ));
1586
+ if (list == null ) {
1587
+ throw new IOException ();
1588
+ }
1589
+ return list ;
1576
1590
}
1577
1591
1578
1592
protected void loadHardware (File folder ) {
0 commit comments