use preconditions instead of try...catch

This commit is contained in:
Edward Chow
2022-11-12 22:26:08 +11:00
parent 1486826883
commit 1414ab4681

View File

@@ -1,5 +1,6 @@
package org.cryptomator.ui.traymenu;
import dagger.internal.Preconditions;
import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.integrations.common.CheckAvailability;
import org.cryptomator.integrations.common.Priority;
@@ -64,17 +65,13 @@ public class AwtTrayMenuController implements TrayMenuController {
@Override
public void onBeforeOpenMenu(Runnable listener) {
try {
this.trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
listener.run();
}
});
} catch (Exception e) {
throw new IllegalStateException("Tray icon not found.", e);
}
Preconditions.checkNotNull(this.trayIcon);
this.trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
listener.run();
}
});
}
private void addChildren(Menu menu, List<TrayMenuItem> items) {