@@ -1153,9 +1153,14 @@ public void onBoardOrPortChange() {
1153
1153
// Populate importToLibraryTable
1154
1154
importToLibraryTable = new HashMap <String , File >();
1155
1155
for (File subfolder : libraries .values ()) {
1156
- String packages [] = headerListFromIncludePath (subfolder );
1157
- for (String pkg : packages )
1158
- importToLibraryTable .put (pkg , subfolder );
1156
+ try {
1157
+ String packages [] = headerListFromIncludePath (subfolder );
1158
+ for (String pkg : packages ) {
1159
+ importToLibraryTable .put (pkg , subfolder );
1160
+ }
1161
+ } catch (IOException e ) {
1162
+ showWarning (_ ("Error" ), I18n .format ("Unable to list header files in {0}" , subfolder ), e );
1163
+ }
1159
1164
}
1160
1165
1161
1166
// Update editors status bar
@@ -1501,8 +1506,13 @@ protected void addLibraries(JMenu menu, Map<String, File> libs) throws IOExcepti
1501
1506
Collections .sort (list , String .CASE_INSENSITIVE_ORDER );
1502
1507
1503
1508
ActionListener listener = new ActionListener () {
1504
- public void actionPerformed (ActionEvent e ) {
1505
- activeEditor .getSketch ().importLibrary (e .getActionCommand ());
1509
+ public void actionPerformed (ActionEvent event ) {
1510
+ String jarPath = event .getActionCommand ();
1511
+ try {
1512
+ activeEditor .getSketch ().importLibrary (jarPath );
1513
+ } catch (IOException e ) {
1514
+ showWarning (_ ("Error" ), I18n .format ("Unable to list header files in {0}" , jarPath ), e );
1515
+ }
1506
1516
}
1507
1517
};
1508
1518
@@ -1524,8 +1534,12 @@ public void actionPerformed(ActionEvent e) {
1524
1534
* the header files in its sub-folders, as those should be included from
1525
1535
* within the header files at the top-level).
1526
1536
*/
1527
- static public String [] headerListFromIncludePath (File path ) {
1528
- return path .list (new OnlyFilesWithExtension (".h" ));
1537
+ static public String [] headerListFromIncludePath (File path ) throws IOException {
1538
+ String [] list = path .list (new OnlyFilesWithExtension (".h" ));
1539
+ if (list == null ) {
1540
+ throw new IOException ();
1541
+ }
1542
+ return list ;
1529
1543
}
1530
1544
1531
1545
protected void loadHardware (File folder ) {
0 commit comments