Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show stacktrace in error popup at view exceptions #5011

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import bisq.common.app.DevEnv;
import bisq.common.app.Log;
import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.config.Config;
import bisq.common.util.InvalidVersionException;
import bisq.common.util.Utilities;
Expand Down Expand Up @@ -273,7 +274,8 @@ public void addBisqSetupListener(BisqSetupListener listener) {

public void start() {
// If user tried to downgrade we require a shutdown
if (hasDowngraded(downGradePreventionHandler)) {
if (Config.baseCurrencyNetwork() == BaseCurrencyNetwork.BTC_MAINNET &&
hasDowngraded(downGradePreventionHandler)) {
return;
}

Expand Down
22 changes: 19 additions & 3 deletions desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
import bisq.desktop.common.view.ViewFactory;
import bisq.desktop.common.view.ViewLoader;

import bisq.common.util.Utilities;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.google.common.base.Joiner;

import javafx.fxml.FXMLLoader;

import java.net.URL;
Expand All @@ -36,8 +40,11 @@

import java.lang.annotation.Annotation;

import lombok.extern.slf4j.Slf4j;

import static com.google.common.base.Preconditions.checkNotNull;

@Slf4j
@Singleton
public class FxmlViewLoader implements ViewLoader {

Expand Down Expand Up @@ -107,7 +114,17 @@ private View loadFromFxml(URL fxmlUrl) {
"does not implement [%s] as expected.", controller.getClass(), fxmlUrl, View.class);
return (View) controller;
} catch (IOException ex) {
throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl);
Throwable cause = ex.getCause();
if (cause != null) {
cause.printStackTrace();
log.error(cause.toString());
// We want to show stackTrace in error popup
String stackTrace = Utilities.toTruncatedString(Joiner.on("\n").join(cause.getStackTrace()), 800, false);
throw new ViewfxException(cause, "%s at loading view class\nStack trace:\n%s",
cause.getClass().getSimpleName(), stackTrace);
} else {
throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl);
}
}
}

Expand All @@ -122,8 +139,7 @@ private static Object getDefaultValue(Class<? extends Annotation> annotationType
}
try {
return annotationType.getDeclaredMethod(attributeName).getDefaultValue();
}
catch (Exception ex) {
} catch (Exception ex) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import javax.inject.Singleton;

import java.util.HashMap;
import java.util.Map;

@Singleton
public class CachingViewLoader implements ViewLoader {

private final HashMap<Object, View> cache = new HashMap<>();
private final Map<Class<? extends View>, View> cache = new HashMap<>();
private final ViewLoader viewLoader;

@Inject
Expand Down