Skip to content

Commit

Permalink
Error handling message is condensed into ProjectIO, better error hand…
Browse files Browse the repository at this point in the history
…ling during specular fit.
  • Loading branch information
denneyl2711 committed Aug 7, 2024
1 parent 2d65b8b commit 2cb1272
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 44 deletions.
31 changes: 8 additions & 23 deletions src/kintsugi3d/builder/core/IBRRequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@

package kintsugi3d.builder.core;

import java.util.LinkedList;
import java.util.Queue;

import javafx.scene.control.*;
import kintsugi3d.builder.javafx.controllers.menubar.MenubarController;
import kintsugi3d.gl.interactive.GraphicsRequest;
import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import kintsugi3d.builder.javafx.ProjectIO;
import kintsugi3d.builder.rendering.IBRInstanceManager;
import kintsugi3d.gl.core.Context;
import kintsugi3d.gl.interactive.GraphicsRequest;
import kintsugi3d.gl.interactive.ObservableGraphicsRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.LinkedList;
import java.util.Queue;

public class IBRRequestManager<ContextType extends Context<ContextType>> implements IBRRequestQueue<ContextType>
{
Expand Down Expand Up @@ -149,21 +148,7 @@ public synchronized void addIBRRequest(ObservableIBRRequest request)
}
catch (Exception | AssertionError e)
{
log.error("Error occurred while executing request:", e);
Platform.runLater(() ->
{
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
ButtonType showLog = new ButtonType("Show Log", ButtonBar.ButtonData.YES);
Alert alert = new Alert(Alert.AlertType.NONE,
"An error occurred processing request. Processing has stopped\nSee the log for more info.",
ok, showLog);

((ButtonBase) alert.getDialogPane().lookupButton(showLog)).setOnAction(event -> {
// Use the menubar's console open function to prevent 2 console windows from appearing
MenubarController.getInstance().help_console();
});
alert.show();
});
ProjectIO.handleException("Error occured while excecuting request", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import kintsugi3d.builder.fit.SpecularFitProcess;
import kintsugi3d.builder.fit.SpecularFitProgramFactory;
import kintsugi3d.builder.fit.settings.SpecularFitRequestParams;
import kintsugi3d.builder.javafx.ProjectIO;
import kintsugi3d.builder.javafx.controllers.menubar.MenubarController;
import kintsugi3d.builder.metrics.ColorAppearanceRMSE;
import kintsugi3d.builder.resources.ibr.ReadonlyIBRResources;
Expand Down Expand Up @@ -105,7 +106,7 @@ public <ContextType extends Context<ContextType>> void executeRequest(IBRInstanc
}
catch(IOException e) // thrown by createReflectanceProgram
{
log.error("Error executing specular fit request:", e);
ProjectIO.handleException("Error executing specular fit request:", e);
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/kintsugi3d/builder/javafx/ProjectIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public void fail(Throwable e)
projectLoaded = false;
if (e instanceof MeshImportException)
{
//TODO: change to (e.getMessage(), e)?
handleException("Imported object is missing texture coordinates", e);
handleException(e.getMessage(), e);
}
else
{
Expand Down Expand Up @@ -149,7 +148,7 @@ public boolean isProjectLoaded()
return projectLoaded;
}

private static void handleException(String message, Throwable e)
public static void handleException(String message, Throwable e)
{
log.error("{}:", message, e);
Platform.runLater(() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

import static kintsugi3d.builder.javafx.ProjectIO.handleException;

public class MenubarController
{
private static final Logger log = LoggerFactory.getLogger(MenubarController.class);
Expand Down Expand Up @@ -405,8 +407,6 @@ public void complete()
{
this.maximum = 0.0;
ProgressBarsController.getInstance().endStopwatches();
//TODO: desaturate progress bars instead of hiding stage
// ProgressBarsController.getInstance().hideStage();
setReadyToDismissMiniProgBar();

if(overallProgressBar.getProgress() == ProgressIndicator.INDETERMINATE_PROGRESS){
Expand Down Expand Up @@ -1052,21 +1052,6 @@ public void launchViewerApp()
}
}

private void handleException(String message, Exception e)
{
log.error("{}:", message, e);
Platform.runLater(() ->
{
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
ButtonType showLog = new ButtonType("Show Log", ButtonBar.ButtonData.YES);
Alert alert = new Alert(AlertType.ERROR, message + "\nSee the log for more info.", ok, showLog);
((Button) alert.getDialogPane().lookupButton(showLog)).setOnAction(event -> {
help_console();
});
alert.show();
});
}

public void file_removeInvalidReferences() {
RecentProjects.removeInvalidReferences();
}
Expand Down

0 comments on commit 2cb1272

Please sign in to comment.