mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-29 17:58:56 -04:00
Introduce FatalException
Rather than throwing a generic RuntimeException for fatal / catastrophic exceptions (which are typically due to developer error) throw FatalException.
This commit is contained in:
parent
e08c2bb564
commit
ce9aca0d1e
2 changed files with 35 additions and 1 deletions
30
src/main/java/io/bitsquare/FatalException.java
Normal file
30
src/main/java/io/bitsquare/FatalException.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bitsquare.
|
||||||
|
*
|
||||||
|
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.bitsquare;
|
||||||
|
|
||||||
|
@SuppressWarnings("serializable")
|
||||||
|
public class FatalException extends RuntimeException {
|
||||||
|
|
||||||
|
public FatalException(String format, Object... args) {
|
||||||
|
super(String.format(format, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FatalException(Throwable cause, String format, Object... args) {
|
||||||
|
super(String.format(format, args), cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package io.bitsquare.util;
|
package io.bitsquare.util;
|
||||||
|
|
||||||
|
import io.bitsquare.FatalException;
|
||||||
import io.bitsquare.gui.Navigation;
|
import io.bitsquare.gui.Navigation;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
|
|
||||||
|
@ -56,6 +57,9 @@ public class ViewLoader {
|
||||||
|
|
||||||
public ViewLoader(Navigation.Item navItem, boolean useCaching) {
|
public ViewLoader(Navigation.Item navItem, boolean useCaching) {
|
||||||
this.url = ViewLoader.class.getResource(navItem.getFxmlUrl());
|
this.url = ViewLoader.class.getResource(navItem.getFxmlUrl());
|
||||||
|
if (this.url == null) {
|
||||||
|
throw new FatalException("'%s' could not be loaded as a resource", navItem.getFxmlUrl());
|
||||||
|
}
|
||||||
|
|
||||||
isCached = useCaching && cachedGUIItems.containsKey(url);
|
isCached = useCaching && cachedGUIItems.containsKey(url);
|
||||||
if (!isCached) {
|
if (!isCached) {
|
||||||
|
@ -85,7 +89,7 @@ public class ViewLoader {
|
||||||
cachedGUIItems.put(url, item);
|
cachedGUIItems.put(url, item);
|
||||||
return result;
|
return result;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to load view at " + url, e);
|
throw new FatalException(e, "Failed to load view at %s", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue