Rework error event builder

This commit is contained in:
crschnick
2025-06-11 01:06:17 +00:00
parent c99d8de028
commit 39872b2411
141 changed files with 534 additions and 515 deletions

View File

@@ -6,7 +6,7 @@ import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.DataStoreFormatter;
import io.xpipe.app.util.LabelGraphic;
@@ -132,14 +132,14 @@ public abstract class AbstractAction {
return;
}
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
return;
}
try {
executeImpl();
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
} finally {
afterExecute();
synchronized (active) {

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.action;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.util.ModuleLayerLoader;
@@ -17,7 +17,7 @@ public interface ActionProvider {
try {
actionProvider.init();
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
}
}
TrackEvent.trace("Finished action provider initialization");

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.beacon;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.DocumentationLink;
import io.xpipe.beacon.BeaconConfig;
@@ -75,7 +75,7 @@ public class AppBeaconServer {
} catch (Exception ex) {
// Not terminal!
// We can still continue without the running server
ErrorEvent.fromThrowable("Unable to start local http server on port " + INSTANCE.getPort(), ex)
ErrorEventFactory.fromThrowable("Unable to start local http server on port " + INSTANCE.getPort(), ex)
.build()
.handle();
}
@@ -135,7 +135,7 @@ public class AppBeaconServer {
t.setDaemon(true);
t.setName("http handler");
t.setUncaughtExceptionHandler((t1, e) -> {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
});
return t;
});

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.beacon;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ThreadHelper;
@@ -106,12 +106,12 @@ public class BeaconRequestHandler<T> implements HttpHandler {
response = beaconInterface.handle(exchange, object);
}
} catch (BeaconClientException clientException) {
ErrorEvent.fromThrowable(clientException).omit().expected().handle();
ErrorEventFactory.fromThrowable(clientException).omit().expected().handle();
writeError(exchange, new BeaconClientErrorResponse(clientException.getMessage()), 400);
return;
} catch (BeaconServerException serverException) {
var cause = serverException.getCause() != null ? serverException.getCause() : serverException;
var event = ErrorEvent.fromThrowable(cause).omit().handle();
var event = ErrorEventFactory.fromThrowable(cause).omit().handle();
var link = event.getLink();
writeError(exchange, new BeaconServerErrorResponse(cause, link), 500);
return;
@@ -119,9 +119,9 @@ public class BeaconRequestHandler<T> implements HttpHandler {
// Handle serialization errors as normal exceptions and other IO exceptions as assuming that the connection
// is broken
if (!ex.getClass().getName().contains("jackson")) {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
} else {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
// Make deserialization error message more readable
var message = ex.getMessage()
.replace("$RequestBuilder", "")
@@ -133,7 +133,7 @@ public class BeaconRequestHandler<T> implements HttpHandler {
}
return;
} catch (Throwable other) {
var event = ErrorEvent.fromThrowable(other).omit().expected().handle();
var event = ErrorEventFactory.fromThrowable(other).omit().expected().handle();
var link = event.getLink();
writeError(exchange, new BeaconServerErrorResponse(other, link), 500);
return;
@@ -159,10 +159,10 @@ public class BeaconRequestHandler<T> implements HttpHandler {
} catch (IOException ioException) {
// The exchange implementation might have already sent a response manually
if (!"headers already sent".equals(ioException.getMessage())) {
ErrorEvent.fromThrowable(ioException).omit().expected().handle();
ErrorEventFactory.fromThrowable(ioException).omit().expected().handle();
}
} catch (Throwable other) {
var event = ErrorEvent.fromThrowable(other).handle();
var event = ErrorEventFactory.fromThrowable(other).handle();
var link = event.getLink();
writeError(exchange, new BeaconServerErrorResponse(other, link), 500);
}
@@ -177,7 +177,7 @@ public class BeaconRequestHandler<T> implements HttpHandler {
os.write(bytes);
}
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.beacon;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.ShellTemp;
import io.xpipe.beacon.BeaconClientException;
@@ -36,7 +36,7 @@ public class BlobManager {
} catch (IOException ignored) {
}
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.beacon.impl;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.beacon.BeaconClientException;
@@ -42,10 +42,10 @@ public class ConnectionAddExchangeImpl extends ConnectionAddExchange {
}
} catch (Throwable ex) {
if (ex instanceof ValidationException) {
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
} else if (ex instanceof StackOverflowError) {
// Cycles in connection graphs can fail hard but are expected
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
}
throw ex;
} finally {

View File

@@ -3,7 +3,7 @@ package io.xpipe.app.browser.action.impl;
import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.browser.action.BrowserActionProvider;
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ProcessOutputException;
@@ -56,7 +56,7 @@ public class RunCommandInBackgroundActionProvider implements BrowserActionProvid
// Only throw actual error output
if (exitCode != 0) {
throw ErrorEvent.expected(ProcessOutputException.of(exitCode, out.get(), err.get()));
throw ErrorEventFactory.expected(ProcessOutputException.of(exitCode, out.get(), err.get()));
}
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.browser.file;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.GlobalClipboard;
import io.xpipe.core.store.FileEntry;
@@ -14,7 +14,6 @@ import javafx.scene.input.Dragboard;
import lombok.SneakyThrows;
import lombok.Value;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.io.File;
@@ -59,7 +58,7 @@ public class BrowserClipboard {
currentCopyClipboard.setValue(
new Instance(UUID.randomUUID(), null, entries, BrowserFileTransferMode.COPY));
} catch (Exception e) {
ErrorEvent.fromThrowable(e).expected().omit().handle();
ErrorEventFactory.fromThrowable(e).expected().omit().handle();
}
}
});

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.browser.file;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileEntry;
@@ -129,12 +129,12 @@ public final class BrowserFileListModel {
exists = fileSystemModel.getFileSystem().fileExists(newFullPath)
|| fileSystemModel.getFileSystem().directoryExists(newFullPath);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return old;
}
if (exists) {
ErrorEvent.fromMessage("Target " + newFullPath + " does already exist")
ErrorEventFactory.fromMessage("Target " + newFullPath + " does already exist")
.expected()
.handle();
fileSystemModel.refresh();
@@ -152,7 +152,7 @@ public final class BrowserFileListModel {
.orElse(old);
return b;
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return old;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.browser.file;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.*;
@@ -56,7 +56,7 @@ public class BrowserFileSystemHelper {
.readStdoutOrThrow();
return !r.isBlank() ? r : null;
} catch (Exception ex) {
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
throw ex;
}
}
@@ -100,14 +100,14 @@ public class BrowserFileSystemHelper {
}
if (verifyExists && !model.getFileSystem().directoryExists(path)) {
throw ErrorEvent.expected(new IllegalArgumentException(
throw ErrorEventFactory.expected(new IllegalArgumentException(
String.format("Directory %s does not exist or is not accessible", path)));
}
try {
model.getFileSystem().directoryAccessible(path);
} catch (Exception ex) {
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
throw ex;
}
}
@@ -131,7 +131,7 @@ public class BrowserFileSystemHelper {
try {
file.getFileSystem().delete(file.getPath());
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
}
}
}

View File

@@ -11,7 +11,7 @@ import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.ext.ShellStore;
import io.xpipe.app.ext.WrapperFileSystem;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.terminal.*;
@@ -140,7 +140,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
try {
fileSystem.close();
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
});
}
@@ -283,7 +283,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
// Start shell in case we exited
startIfNeeded();
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return Optional.ofNullable(cps);
}
@@ -303,7 +303,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
try {
evaluatedPath = BrowserFileSystemHelper.evaluatePath(this, adjustedPath);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return Optional.ofNullable(cps);
}
@@ -351,7 +351,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
try {
resolvedPath = BrowserFileSystemHelper.resolveDirectoryPath(this, FilePath.of(evaluatedPath), customInput);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return Optional.ofNullable(cps);
}
@@ -363,7 +363,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
BrowserFileSystemHelper.validateDirectoryPath(this, resolvedPath, true);
cdSyncWithoutCheck(resolvedPath);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return Optional.ofNullable(cps);
}
@@ -409,7 +409,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
return true;
} catch (Exception e) {
fileList.setAll(Stream.of());
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return false;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.browser.file;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.*;
@@ -192,7 +192,7 @@ public class BrowserFileTransferOperation {
}
if (source.getKind() == FileKind.DIRECTORY && target.getFileSystem().directoryExists(targetFile)) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalArgumentException("Target directory " + targetFile + " does already exist"));
}
@@ -401,7 +401,7 @@ public class BrowserFileTransferOperation {
} catch (Exception om) {
// This is expected as the process control has to be killed
// When calling close, it will throw an exception when it has to kill
ErrorEvent.fromThrowable(om).expected().omit().handle();
ErrorEventFactory.fromThrowable(om).expected().omit().handle();
}
}
if (outputStream != null) {
@@ -410,7 +410,7 @@ public class BrowserFileTransferOperation {
} catch (Exception om) {
// This is expected as the process control has to be killed
// When calling close, it will throw an exception when it has to kill
ErrorEvent.fromThrowable(om).expected().omit().handle();
ErrorEventFactory.fromThrowable(om).expected().omit().handle();
}
}
throw ex;
@@ -447,8 +447,8 @@ public class BrowserFileTransferOperation {
cancelled.removeListener(closeCancelListener);
if (exception != null) {
ErrorEvent.preconfigure(
ErrorEvent.fromThrowable(exception).reportable(!cancelled()).omitted(cancelled()));
ErrorEventFactory.preconfigure(
ErrorEventFactory.fromThrowable(exception).reportable(!cancelled()).omitted(cancelled()));
throw exception;
}
}

View File

@@ -4,7 +4,7 @@ import io.xpipe.app.comp.SimpleComp;
import io.xpipe.app.comp.base.SimpleTitledPaneComp;
import io.xpipe.app.comp.base.VerticalComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.DerivedObservableList;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.ShellControl;
@@ -45,7 +45,7 @@ public class BrowserOverviewComp extends SimpleComp {
try {
return fs.directoryExists(entry.getPath());
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return false;
}
})

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.browser.file;
import io.xpipe.app.browser.BrowserFullSessionModel;
import io.xpipe.app.browser.action.impl.TransferFilesActionProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.DesktopHelper;
@@ -79,7 +79,7 @@ public class BrowserTransferModel {
try {
FileUtils.forceDelete(item.getLocalFile().toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -120,7 +120,7 @@ public class BrowserTransferModel {
try {
FileUtils.forceMkdir(TEMP.toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return;
}
@@ -159,7 +159,7 @@ public class BrowserTransferModel {
.build();
action.executeSync();
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
synchronized (items) {
items.remove(item);
}

View File

@@ -7,7 +7,7 @@ import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.ContextualFileReference;
import io.xpipe.app.storage.DataStorageSyncHandler;
@@ -105,7 +105,7 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
try {
var source = currentPath.asLocalPath();
if (!Files.exists(source)) {
ErrorEvent.fromMessage("Unable to resolve local file path " + source)
ErrorEventFactory.fromMessage("Unable to resolve local file path " + source)
.expected()
.handle();
return;
@@ -131,7 +131,7 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
filePath.setValue(FilePath.of(syncedTarget));
});
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
});
gitShareButton.tooltipKey("gitShareFileTooltip");

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.comp.base;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.util.FailableConsumer;
import javafx.geometry.Pos;
@@ -73,7 +73,7 @@ public class FileDropOverlayComp<T extends CompStructure<?>> extends Comp<FileDr
try {
fileConsumer.accept(list);
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
}
}
event.consume();

View File

@@ -5,7 +5,7 @@ import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.MarkdownHelper;
@@ -83,7 +83,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
return file;
} catch (IOException e) {
// Any possible IO errors can occur here
ErrorEvent.fromThrowable(e).expected().handle();
ErrorEventFactory.fromThrowable(e).expected().handle();
return null;
}
}
@@ -155,7 +155,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
WEB_VIEW_SUPPORTED = true;
sp.getChildren().addAll(wv);
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
WEB_VIEW_SUPPORTED = false;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.LogErrorHandler;
import io.xpipe.core.util.XPipeDaemonMode;
@@ -62,14 +62,14 @@ public class AppArguments {
public static LauncherCommand resolveLauncher(String[] args) {
var cmd = new CommandLine(new LauncherCommand());
cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
var event = ErrorEvent.fromThrowable(ex).term().build();
var event = ErrorEventFactory.fromThrowable(ex).term().build();
// Print error in case we launched from the command-line
new LogErrorHandler().handle(event);
event.handle();
return 1;
});
cmd.setParameterExceptionHandler((ex, args1) -> {
var event = ErrorEvent.fromThrowable(ex).term().expected().build();
var event = ErrorEventFactory.fromThrowable(ex).term().expected().build();
// Print error in case we launched from the command-line
new LogErrorHandler().handle(event);
event.handle();
@@ -89,7 +89,7 @@ public class AppArguments {
var converted = t instanceof CommandLine.UnmatchedArgumentException u
? new IllegalArgumentException(u.getMessage())
: t;
var e = ErrorEvent.fromThrowable(converted).expected().term().build();
var e = ErrorEventFactory.fromThrowable(converted).expected().term().build();
// Print error in case we launched from the command-line
new LogErrorHandler().handle(e);
e.handle();

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.util.JacksonMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -34,7 +34,7 @@ public class AppCache {
try {
FileUtils.cleanDirectory(getBasePath().toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -65,7 +65,7 @@ public class AppCache {
return r;
}
} catch (Exception ex) {
ErrorEvent.fromThrowable("Could not parse cached data for key " + key, ex)
ErrorEventFactory.fromThrowable("Could not parse cached data for key " + key, ex)
.omit()
.expected()
.handle();
@@ -88,7 +88,7 @@ public class AppCache {
return tree.asBoolean();
} catch (Exception ex) {
ErrorEvent.fromThrowable("Could not parse cached data for key " + key, ex)
ErrorEventFactory.fromThrowable("Could not parse cached data for key " + key, ex)
.omit()
.expected()
.handle();
@@ -105,7 +105,7 @@ public class AppCache {
FileUtils.forceMkdirParent(path.toFile());
JacksonMapper.getDefault().writeValue(path.toFile(), val);
} catch (Exception e) {
ErrorEvent.fromThrowable("Could not write cache data for key " + key, e)
ErrorEventFactory.fromThrowable("Could not write cache data for key " + key, e)
.omitted(true)
.expected()
.build()
@@ -120,7 +120,7 @@ public class AppCache {
var t = Files.getLastModifiedTime(path);
return Optional.of(t.toInstant());
} catch (Exception e) {
ErrorEvent.fromThrowable("Could not get modified date for " + key, e)
ErrorEventFactory.fromThrowable("Could not get modified date for " + key, e)
.omitted(true)
.expected()
.build()

View File

@@ -1,7 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import org.apache.commons.io.FileUtils;
import java.io.RandomAccessFile;
@@ -37,7 +36,7 @@ public class AppDataLock {
lock = channel.tryLock();
return lock != null;
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).build().handle();
ErrorEventFactory.fromThrowable(ex).build().handle();
return false;
}
}
@@ -53,7 +52,7 @@ public class AppDataLock {
lock = null;
channel = null;
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).build().handle();
ErrorEventFactory.fromThrowable(ex).build().handle();
}
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.core;
import io.xpipe.app.Main;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorageUserHandler;
import io.xpipe.app.util.PlatformState;
@@ -79,12 +79,12 @@ public class AppDesktopIntegration {
Taskbar.getTaskbar().setIconImage(awtIcon);
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(ex).omitted(true).build().handle();
}
}
}
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).term().handle();
ErrorEventFactory.fromThrowable(ex).term().handle();
}
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.core;
import io.xpipe.app.ext.ExtensionException;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.ModuleAccess;
import io.xpipe.core.process.OsType;
@@ -43,7 +43,7 @@ public class AppExtensionManager {
try {
ProcessControlProvider.init(INSTANCE.extendedLayer);
ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, t -> {
ErrorEvent.fromThrowable(t).handle();
ErrorEventFactory.fromThrowable(t).handle();
});
} catch (Throwable t) {
throw ExtensionException.corrupt("Service provider initialization failed", t);
@@ -186,7 +186,7 @@ public class AppExtensionManager {
return Optional.of(mod);
}
} catch (Throwable t) {
ErrorEvent.fromThrowable(t)
ErrorEventFactory.fromThrowable(t)
.description("Unable to load extension from " + dir + ". Is the installation corrupted?")
.handle();
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.ThreadHelper;
@@ -53,7 +53,7 @@ public class AppFileWatcher {
try {
watchService = FileSystems.getDefault().newWatchService();
} catch (IOException e) {
ErrorEvent.fromThrowable(
ErrorEventFactory.fromThrowable(
"Unable to initialize file watcher. Watching and updating files in the file browser will be unavailable.",
e)
.expected()
@@ -79,7 +79,7 @@ public class AppFileWatcher {
break;
} catch (Exception ex) {
// Catch all other exceptions to not terminate this thread if an error occurs!
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
// Don't sleep, since polling the directories always sleeps for some ms
@@ -100,13 +100,13 @@ public class AppFileWatcher {
try {
watchService.close();
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
try {
watcherThread.join();
} catch (InterruptedException e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
}
@@ -132,7 +132,7 @@ public class AppFileWatcher {
dir.register(AppFileWatcher.this.watchService, ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE);
Files.list(dir).filter(Files::isDirectory).forEach(this::createRecursiveWatchers);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
}
@@ -176,7 +176,7 @@ public class AppFileWatcher {
try {
file.register(AppFileWatcher.this.watchService, ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.SupportedLocale;
@@ -108,7 +108,7 @@ public class AppI18n {
Locale.setDefault(n != null ? n.getLocale() : Locale.ENGLISH);
});
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
});
});

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.SupportedLocale;
import io.xpipe.core.util.XPipeInstallation;
@@ -82,7 +82,7 @@ public class AppI18nData {
lineCounter.incrementAndGet();
});
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(ex).omitted(true).build().handle();
}
return FileVisitResult.CONTINUE;
}
@@ -109,7 +109,7 @@ public class AppI18nData {
try (var in = Files.newInputStream(file)) {
markdownDocumentations.put(name, new String(in.readAllBytes(), StandardCharsets.UTF_8));
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(ex).omitted(true).build().handle();
}
return FileVisitResult.CONTINUE;
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import javafx.scene.image.Image;
@@ -153,7 +153,7 @@ public class AppImages {
try (var in = Files.newInputStream(p)) {
return new Image(in, -1, -1, true, true);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(e).omitted(true).build().handle();
return DEFAULT_IMAGE;
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.core;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.beacon.BeaconClient;
@@ -73,7 +73,7 @@ public class AppInstance {
}
var cli = XPipeInstallation.getLocalDefaultCliExecutable();
ErrorEvent.fromThrowable(
ErrorEventFactory.fromThrowable(
"Unable to connect to existing running daemon instance as it did not respond."
+ " Either try to kill the process xpiped manually or use the command \""
+ cli
@@ -92,7 +92,7 @@ public class AppInstance {
.arguments(List.of(e.getURI().toString()))
.build());
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
}
});
ThreadHelper.sleep(1000);

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.util.Deobfuscator;
@@ -120,7 +120,7 @@ public class AppLogs {
} catch (Exception ex) {
// It can happen that another instance is running that is locking a log file
// Since we initialized before checking for another instance, this might fail
ErrorEvent.fromThrowable(ex).expected().omit().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
}
}
@@ -143,7 +143,7 @@ public class AppLogs {
var buf = new BufferedOutputStream(fos);
outFileStream = new PrintStream(buf, false);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).build().handle();
ErrorEventFactory.fromThrowable(ex).build().handle();
}
}

View File

@@ -5,7 +5,7 @@ import io.xpipe.app.action.ActionProvider;
import io.xpipe.app.action.LauncherActionProvider;
import io.xpipe.app.browser.action.impl.OpenDirectoryActionProvider;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.core.store.FilePath;
@@ -53,7 +53,7 @@ public class AppOpenArguments {
try {
all.addAll(parseActions(s));
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
});
@@ -87,7 +87,7 @@ public class AppOpenArguments {
try {
a = ((LauncherActionProvider) found.get()).createAction(uri);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().expected().handle();
ErrorEventFactory.fromThrowable(e).omit().expected().handle();
return List.of();
}
return a != null ? List.of(a) : List.of();

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core;
import io.xpipe.app.core.check.AppUserDirectoryCheck;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.util.XPipeDaemonMode;
@@ -78,7 +78,7 @@ public class AppProperties {
}
});
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
var referenceDir = Files.exists(appDir) ? appDir : Path.of(System.getProperty("user.dir"));

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.util.FailableConsumer;
import io.xpipe.modulefs.ModuleFileSystem;
@@ -62,7 +62,7 @@ public class AppResources {
var url = f.getWrappedPath().toUri().toURL();
return Optional.of(url);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(e).omitted(true).build().handle();
return Optional.empty();
}
}
@@ -86,7 +86,7 @@ public class AppResources {
var f = fs.getPath(module.replace('.', '/') + "/resources/" + file);
con.accept(f);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(e).omitted(true).build().handle();
}
}
@@ -97,7 +97,7 @@ public class AppResources {
var f = fs.getPath(path);
con.accept(f);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(e).omitted(true).build().handle();
}
}
@@ -125,7 +125,7 @@ public class AppResources {
con.accept(f);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(e).omitted(true).build().handle();
}
return true;
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.process.OsType;
@@ -28,7 +28,7 @@ public class AppSid {
hasSetsid = p.exitValue() == 0;
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
}
if (hasSetsid) {
@@ -50,7 +50,7 @@ public class AppSid {
func.invoke(new Object[0]);
TrackEvent.info("Successfully set process sid");
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle();
ErrorEventFactory.fromThrowable(t).omit().handle();
}
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
@@ -78,7 +78,7 @@ public class AppStyle {
STYLESHEET_CONTENTS.put(file, s);
}
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
ErrorEventFactory.fromThrowable(ex).omitted(true).build().handle();
}
return FileVisitResult.CONTINUE;
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.core;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ColorHelper;
@@ -124,9 +124,9 @@ public class AppTheme {
});
} catch (IllegalStateException ex) {
// The platform preferences are sometimes not initialized yet
ErrorEvent.fromThrowable(ex).expected().omit().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle();
ErrorEventFactory.fromThrowable(t).omit().handle();
}
var t = AppPrefs.get().theme().getValue();
@@ -200,7 +200,7 @@ public class AppTheme {
}
} catch (IllegalStateException ex) {
// The platform preferences are sometimes not initialized yet
ErrorEvent.fromThrowable(ex).expected().omit().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
} catch (Exception ex) {
// The color scheme query can fail if the toolkit is not initialized properly
AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme());

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.OsType;
import java.awt.*;
@@ -63,7 +63,7 @@ public class AppTrayIcon {
try {
return ImageIO.read(iconImagePath);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return AppImages.toAwtImage(AppImages.DEFAULT_IMAGE);
}
}
@@ -89,7 +89,7 @@ public class AppTrayIcon {
tray.add(this.trayIcon);
} catch (Exception e) {
// This can sometimes fail on Linux
ErrorEvent.fromThrowable("Unable to add TrayIcon", e).expected().handle();
ErrorEventFactory.fromThrowable("Unable to add TrayIcon", e).expected().handle();
}
});
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.ThreadHelper;
@@ -30,7 +30,7 @@ public class AppWindowsShutdown {
PROC.hwnd = hwnd;
PROC.hhook = User32.INSTANCE.SetWindowsHookEx(4, PROC, null, windowThreadID);
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle();
ErrorEventFactory.fromThrowable(t).omit().handle();
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileNames;
@@ -29,7 +29,7 @@ public class AppHomebrewCoreutilsCheck {
var loc = checkCoreutils();
if (loc.isPresent()) {
ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH at "
ErrorEventFactory.fromMessage("You have the homebrew coreutils package installed and added to your PATH at "
+ loc.get() + "."
+ " The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects."
+ " Please remove the coreutils commands from your PATH prior to launching XPipe.")

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
public class AppJavaOptionsCheck {
@@ -15,7 +15,7 @@ public class AppJavaOptionsCheck {
return;
}
ErrorEvent.fromMessage(
ErrorEventFactory.fromMessage(
"You have configured the global environment variable _JAVA_OPTIONS=%s on your system."
.formatted(env)
+ " This will forcefully apply all custom JVM options to XPipe and can cause a variety of different issues."

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.LocalExec;
import io.xpipe.core.process.OsType;
@@ -16,7 +16,7 @@ public class AppPathCorruptCheck {
return;
}
ErrorEvent.fromMessage(
ErrorEventFactory.fromMessage(
"Your system PATH looks to be corrupt, essential system tools are not available. This will cause XPipe to not function correctly. Please make sure to fix your PATH environment variable to include the base Windows tools.")
.expected()
.handle();

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.DocumentationLink;
import io.xpipe.app.util.LocalShell;
import io.xpipe.core.process.OsType;
@@ -25,7 +25,7 @@ public class AppRosettaCheck {
}
if (ret.get().equals("1")) {
ErrorEvent.fromMessage("You are running the Intel version of XPipe on an Apple Silicon system."
ErrorEventFactory.fromMessage("You are running the Intel version of XPipe on an Apple Silicon system."
+ " There is a native build available that comes with much better performance."
+ " Please install that one instead.")
.documentationLink(DocumentationLink.MACOS_SETUP)

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core.check;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.core.process.ProcessOutputException;
@@ -28,7 +28,7 @@ public abstract class AppShellChecker {
&& canFallback
&& (shouldAttemptFallbackForProcessStartFail() || !err.get().isProcessSpawnIssue())) {
var msg = formatMessage(err.get().getMessage());
ErrorEvent.fromThrowable(new IllegalStateException(msg)).expected().handle();
ErrorEventFactory.fromThrowable(new IllegalStateException(msg)).expected().handle();
toggleFallback();
var fallbackErr = selfTestErrorCheck();
if (fallbackErr.isPresent()) {
@@ -40,7 +40,7 @@ public abstract class AppShellChecker {
if (err.isPresent()) {
var msg = formatMessage(err.get().getMessage());
var event = ErrorEvent.fromThrowable(new IllegalStateException(msg));
var event = ErrorEventFactory.fromThrowable(new IllegalStateException(msg));
if (!err.get().isCanContinue()) {
event.term();
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.OsType;
import java.io.IOException;
@@ -20,7 +20,7 @@ public class AppTempCheck {
}
if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir)) {
ErrorEvent.fromThrowable(new IOException("Specified temporary directory " + tmpdir
ErrorEventFactory.fromThrowable(new IOException("Specified temporary directory " + tmpdir
+ ", set via the environment variable %TEMP% is invalid."))
.term()
.expected()

View File

@@ -1,7 +1,6 @@
package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import org.apache.commons.io.FileUtils;
import java.io.IOException;
@@ -21,7 +20,7 @@ public class AppUserDirectoryCheck {
Files.delete(testDirectory);
// if (true) throw new IOException();
} catch (IOException e) {
ErrorEvent.fromThrowable(
ErrorEventFactory.fromThrowable(
"Unable to access directory " + dataDirectory
+ ". Please make sure that you have the appropriate permissions and no Antivirus program is blocking the access. "
+ "In case you use cloud storage, verify that your cloud storage is working and you are logged in.",

View File

@@ -105,7 +105,7 @@ public abstract class OperationMode {
OperationMode.halt(1);
}
ErrorEvent.fromThrowable(ex).unhandled(true).build().handle();
ErrorEventFactory.fromThrowable(ex).unhandled(true).build().handle();
});
TrackEvent.info("Initial setup");
@@ -132,7 +132,7 @@ public abstract class OperationMode {
});
TrackEvent.info("Finished initial setup");
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).term().handle();
ErrorEventFactory.fromThrowable(ex).term().handle();
}
}
@@ -279,7 +279,7 @@ public abstract class OperationMode {
LocalShell.init();
r.run();
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
OperationMode.halt(1);
}
@@ -340,7 +340,7 @@ public abstract class OperationMode {
}
CURRENT = null;
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).term().handle();
ErrorEventFactory.fromThrowable(t).term().handle();
OperationMode.halt(1);
}
@@ -391,7 +391,7 @@ public abstract class OperationMode {
}
CURRENT = newMode;
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).terminal(true).build().handle();
ErrorEventFactory.fromThrowable(ex).terminal(true).build().handle();
}
}

View File

@@ -5,7 +5,7 @@ import io.xpipe.app.comp.base.AppMainWindowContentComp;
import io.xpipe.app.core.*;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.CloseBehaviourDialog;
@@ -152,7 +152,7 @@ public class AppMainWindow {
TrackEvent.info("Window content node structure created");
loadedContent.setValue(s);
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).term().handle();
ErrorEventFactory.fromThrowable(t).term().handle();
}
});
}
@@ -364,7 +364,7 @@ public class AppMainWindow {
try {
ImageIO.write(awt, "png", file.toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
TrackEvent.debug("Screenshot taken");
event.consume();

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.core.window;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.PlatformThread;
import io.xpipe.core.process.OsType;
@@ -18,8 +18,6 @@ import javafx.util.Duration;
import lombok.SneakyThrows;
import org.apache.commons.lang3.SystemUtils;
import java.awt.*;
public class ModifiedStage extends Stage {
public static boolean mergeFrame() {
@@ -123,7 +121,7 @@ public class ModifiedStage extends Stage {
}
}
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle();
ErrorEventFactory.fromThrowable(t).omit().handle();
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.core.window;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.NativeBridge;
import javafx.stage.Window;
@@ -44,7 +44,7 @@ public class NativeMacOsWindowControl {
try {
lib.get().setAppearance(new NativeLong(nsWindow), seamlessFrame, darkMode);
} catch (Throwable e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
return true;
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.ext;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.DocumentationLink;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ShellControl;
@@ -84,7 +84,7 @@ public class ConnectionFileSystem implements FileSystem {
try {
d.throwIfUnsupported();
} catch (Exception e) {
throw ErrorEvent.expected(e);
throw ErrorEventFactory.expected(e);
}
}
@@ -92,7 +92,7 @@ public class ConnectionFileSystem implements FileSystem {
|| !shellControl.getTtyState().isSupportsInput()) {
var ex = new UnsupportedOperationException(
"Shell has a PTY allocated and as a result does not support file system operations.");
ErrorEvent.preconfigure(ErrorEvent.fromThrowable(ex).documentationLink(DocumentationLink.TTY));
ErrorEventFactory.preconfigure(ErrorEventFactory.fromThrowable(ex).documentationLink(DocumentationLink.TTY));
throw ex;
}
@@ -240,7 +240,7 @@ public class ConnectionFileSystem implements FileSystem {
try {
shellControl.close();
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
}
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.ext;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.util.JacksonMapper;
@@ -22,7 +22,7 @@ public class DataStoreProviders {
try {
dataStoreProvider.init();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
});
}
@@ -32,7 +32,7 @@ public class DataStoreProviders {
try {
dataStoreProvider.reset();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
});
}
@@ -74,7 +74,7 @@ public class DataStoreProviders {
p.validate();
return false;
} catch (Throwable e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return true;
}
});

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.ext;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.GlobalTimer;
import io.xpipe.app.util.ThreadHelper;
@@ -31,13 +31,13 @@ public abstract class Session implements AutoCloseable {
return;
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
try {
stop();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
});
return false;

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.ext;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.StubShellControl;
import io.xpipe.core.store.*;
@@ -23,7 +23,7 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
existingSession.getShellControl().command(" echo xpipetest").execute();
return new StubShellControl(existingSession.getShellControl());
} catch (Exception e) {
ErrorEvent.fromThrowable(e).expected().omit().handle();
ErrorEventFactory.fromThrowable(e).expected().omit().handle();
stopSessionIfNeeded();
}
}
@@ -51,11 +51,11 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
session.getShellControl().command(" echo xpipetest").execute();
return true;
} catch (Exception e) {
ErrorEvent.fromThrowable(e).expected().omit().handle();
ErrorEventFactory.fromThrowable(e).expected().omit().handle();
try {
stopSessionIfNeeded();
} catch (Exception se) {
ErrorEvent.fromThrowable(se).expected().omit().handle();
ErrorEventFactory.fromThrowable(se).expected().omit().handle();
}
return false;
}

View File

@@ -8,7 +8,7 @@ import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.ext.DataStoreCreationCategory;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
@@ -99,7 +99,7 @@ public class StoreCreationDialog {
});
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
};
show(

View File

@@ -3,7 +3,7 @@ package io.xpipe.app.hub.comp;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.ShellStore;
import io.xpipe.app.hub.action.impl.LaunchStoreActionProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreCategory;
import io.xpipe.app.storage.DataStoreEntry;
@@ -200,7 +200,7 @@ public class StoreCreationModel {
.getMessages()
.getFirst()
.getText();
ErrorEvent.fromMessage(msg).expected().handle();
ErrorEventFactory.fromMessage(msg).expected().handle();
changedSinceError.setValue(false);
return;
}
@@ -227,15 +227,15 @@ public class StoreCreationModel {
commit(true);
} catch (Throwable ex) {
if (ex instanceof ValidationException) {
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
} else if (ex instanceof StackOverflowError) {
// Cycles in connection graphs can fail hard but are expected
ErrorEvent.expected(ex);
ErrorEventFactory.expected(ex);
}
changedSinceError.setValue(false);
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
} finally {
DataStorage.get().removeStoreEntryInProgress(entry.getValue());
}

View File

@@ -8,7 +8,7 @@ import io.xpipe.app.hub.action.BranchStoreActionProvider;
import io.xpipe.app.hub.action.LeafStoreActionProvider;
import io.xpipe.app.hub.action.StoreActionProvider;
import io.xpipe.app.hub.action.impl.EditStoreActionProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreCategory;
@@ -222,7 +222,7 @@ public class StoreEntryWrapper {
AppPrefs.get().censorMode(),
information));
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
information.bind(new SimpleStringProperty());
}
}
@@ -237,7 +237,7 @@ public class StoreEntryWrapper {
entry.getProvider() != null ? entry.getProvider().summaryString(this) : null);
} catch (Exception ex) {
// Summary creation might fail or have a bug
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
}
@@ -288,7 +288,7 @@ public class StoreEntryWrapper {
minorActionProviders.setAll(newMinorProviders);
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.hub.comp;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.ext.DataStoreUsageCategory;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreCategory;
@@ -161,7 +161,7 @@ public class StoreViewState {
} catch (Exception exception) {
currentTopLevelSection = new StoreSection(
null, DerivedObservableList.arrayList(true), DerivedObservableList.arrayList(true), 0);
ErrorEvent.fromThrowable(exception).handle();
ErrorEventFactory.fromThrowable(exception).handle();
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.icon;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import com.github.weisj.jsvg.SVGDocument;
@@ -91,7 +91,7 @@ public class SystemIconCache {
if (scheme == ImageColorScheme.TRANSPARENT) {
var message = "Failed to rasterize icon "
+ icon.getFile().getFileName().toString() + ": Rasterized image is transparent";
ErrorEvent.fromMessage(message).omit().expected().handle();
ErrorEventFactory.fromMessage(message).omit().expected().handle();
continue;
}
@@ -118,7 +118,7 @@ public class SystemIconCache {
if (scheme == ImageColorScheme.TRANSPARENT) {
var message = "Failed to rasterize icon "
+ icon.getFile().getFileName().toString() + ": Rasterized image is transparent";
ErrorEvent.fromMessage(message).omit().expected().handle();
ErrorEventFactory.fromMessage(message).omit().expected().handle();
}
continue;
@@ -136,7 +136,7 @@ public class SystemIconCache {
}
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -175,7 +175,7 @@ public class SystemIconCache {
return c != null ? c : ImageColorScheme.TRANSPARENT;
} catch (Exception ex) {
var message = "Failed to rasterize icon icon " + path.getFileName().toString() + ": " + ex.getMessage();
ErrorEvent.fromThrowable(ex).description(message).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).description(message).omit().expected().handle();
return ImageColorScheme.TRANSPARENT;
}
}
@@ -196,7 +196,7 @@ public class SystemIconCache {
throw ex;
}
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
}
}

View File

@@ -3,7 +3,7 @@ package io.xpipe.app.icon;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppImages;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.SupportedLocale;
import io.xpipe.app.storage.DataStorage;
@@ -41,7 +41,7 @@ public class SystemIconManager {
try {
pref.checkComplete();
} catch (ValidationException e) {
ErrorEvent.fromThrowable(e).omit().expected().handle();
ErrorEventFactory.fromThrowable(e).omit().expected().handle();
continue;
}
@@ -101,7 +101,7 @@ public class SystemIconManager {
AppImages.loadRasterImages(SystemIconCache.getDirectory(source), "icons/" + source.getId());
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -111,7 +111,7 @@ public class SystemIconManager {
try {
source.refresh();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).expected().handle();
ErrorEventFactory.fromThrowable(e).expected().handle();
}
}
reloadSources();

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.icon;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.Validators;
@@ -97,7 +97,7 @@ public interface SystemIconSource {
if (!present) {
var msg =
"Git command-line tools are not available in the PATH but are required to use icons from a git repository. For more details, see https://git-scm.com/downloads.";
ErrorEvent.fromMessage(msg).expected().handle();
ErrorEventFactory.fromMessage(msg).expected().handle();
return;
}

View File

@@ -1,7 +1,6 @@
package io.xpipe.app.icon;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import lombok.Value;
import org.apache.commons.io.FilenameUtils;
@@ -64,7 +63,7 @@ public class SystemIconSourceData {
}
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
}

View File

@@ -9,14 +9,12 @@ import lombok.Singular;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
@Builder
@Getter
public class ErrorEvent {
private static final Map<Throwable, ErrorEventBuilder> EVENT_BASES = new ConcurrentHashMap<>();
private static final Set<Throwable> HANDLED = new CopyOnWriteArraySet<>();
@Builder.Default
@@ -45,63 +43,6 @@ public class ErrorEvent {
private String userReport;
private boolean unhandled;
public static ErrorEventBuilder fromThrowable(Throwable t) {
if (EVENT_BASES.containsKey(t)) {
return EVENT_BASES.remove(t).description(t.getMessage());
}
return builder().throwable(t).description(t.getMessage());
}
public static ErrorEventBuilder fromThrowable(String msg, Throwable t) {
if (EVENT_BASES.containsKey(t)) {
return EVENT_BASES.remove(t).description(msg);
}
return builder()
.throwable(t)
.description(
msg + (t.getMessage() != null ? "\n\n" + t.getMessage().strip() : ""));
}
public static ErrorEventBuilder fromMessage(String msg) {
return builder().description(msg);
}
public static <T extends Throwable> T expectedIfEndsWith(T t, String... s) {
return expectedIf(
t,
t.getMessage() != null
&& Arrays.stream(s).map(String::toLowerCase).anyMatch(string -> t.getMessage()
.toLowerCase(Locale.ROOT)
.endsWith(string)));
}
public static <T extends Throwable> T expectedIfContains(T t, String... s) {
return expectedIf(
t,
t.getMessage() != null
&& Arrays.stream(s).map(String::toLowerCase).anyMatch(string -> t.getMessage()
.toLowerCase(Locale.ROOT)
.contains(string)));
}
public static <T extends Throwable> T expectedIf(T t, boolean b) {
if (b) {
EVENT_BASES.put(t, ErrorEvent.fromThrowable(t).expected());
}
return t;
}
public static <T extends Throwable> T expected(T t) {
EVENT_BASES.put(t, ErrorEvent.fromThrowable(t).expected());
return t;
}
public static void preconfigure(ErrorEventBuilder event) {
EVENT_BASES.put(event.throwable, event);
}
public void attachUserReport(String email, String text) {
this.email = email;
userReport = text;
@@ -181,5 +122,13 @@ public class ErrorEvent {
expected();
}
}
Throwable getThrowable() {
return throwable;
}
String getLink() {
return link;
}
}
}

View File

@@ -0,0 +1,73 @@
package io.xpipe.app.issue;
import io.xpipe.app.util.DocumentationLink;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ProcessOutputException;
import javax.net.ssl.SSLHandshakeException;
import java.util.Arrays;
import java.util.IdentityHashMap;
import java.util.Locale;
import java.util.Map;
public class ErrorEventFactory {
private static final Map<Throwable, ErrorEvent.ErrorEventBuilder> EVENT_BASES = new IdentityHashMap<>();
public static ErrorEvent.ErrorEventBuilder fromThrowable(Throwable t) {
var b = retrieveBuilder(t);
return b.description(t.getMessage());
}
public static ErrorEvent.ErrorEventBuilder fromThrowable(String msg, Throwable t) {
var b = retrieveBuilder(t);
return b.description(msg + (t.getMessage() != null ? "\n\n" + t.getMessage().strip() : ""));
}
public static ErrorEvent.ErrorEventBuilder fromMessage(String msg) {
return ErrorEvent.builder().description(msg);
}
public static <T extends Throwable> T expectedIfContains(T t, String... s) {
return expectedIf(
t,
t.getMessage() != null
&& Arrays.stream(s).map(String::toLowerCase).anyMatch(string -> t.getMessage()
.toLowerCase(Locale.ROOT)
.contains(string)));
}
public static <T extends Throwable> T expectedIf(T t, boolean b) {
if (b) {
preconfigure(fromThrowable(t).expected());
}
return t;
}
public static <T extends Throwable> T expected(T t) {
preconfigure(fromThrowable(t).expected());
return t;
}
public static synchronized void preconfigure(ErrorEvent.ErrorEventBuilder event) {
EVENT_BASES.put(event.getThrowable(), event);
}
private static synchronized ErrorEvent.ErrorEventBuilder retrieveBuilder(Throwable t) {
var b = EVENT_BASES.remove(t);
if (b == null) {
b = ErrorEvent.builder().throwable(t);
}
if (t instanceof SSLHandshakeException && b.getLink() == null) {
b.documentationLink(DocumentationLink.TLS_DECRYPTION);
}
// Indicates that the session is scheduled to end and new processes won't be started
if (OsType.getLocal() == OsType.WINDOWS && t instanceof ProcessOutputException pex && pex.getExitCode() == -1073741205) {
b.expected();
}
return b;
}
}

View File

@@ -72,7 +72,7 @@ public class ErrorHandlerDialog {
comp.getTakenAction().setValue(ErrorAction.ignore());
}
} catch (Throwable t) {
ErrorAction.ignore().handle(ErrorEvent.fromThrowable(t).build());
ErrorAction.ignore().handle(ErrorEventFactory.fromThrowable(t).build());
ErrorAction.ignore().handle(event);
}
}

View File

@@ -19,7 +19,7 @@ public class GuiErrorHandler extends GuiErrorHandlerBase implements ErrorHandler
log.handle(event);
if (!startupGui(throwable -> {
var second = ErrorEvent.fromThrowable(throwable).build();
var second = ErrorEventFactory.fromThrowable(throwable).build();
log.handle(second);
ErrorAction.ignore().handle(second);
})) {

View File

@@ -63,7 +63,7 @@ public class TerminalErrorHandler extends GuiErrorHandlerBase implements ErrorHa
private void handleWithSecondaryException(ErrorEvent event, Throwable t) {
ErrorAction.ignore().handle(event);
var second = ErrorEvent.fromThrowable(t).build();
var second = ErrorEventFactory.fromThrowable(t).build();
log.handle(second);
ErrorAction.ignore().handle(second);
ThreadHelper.sleep(1000);
@@ -87,7 +87,7 @@ public class TerminalErrorHandler extends GuiErrorHandlerBase implements ErrorHa
AppDialog.showAndWait(updateModal);
}
} catch (Throwable t) {
var event = ErrorEvent.fromThrowable(t).build();
var event = ErrorEventFactory.fromThrowable(t).build();
log.handle(event);
ErrorAction.ignore().handle(event);
ThreadHelper.sleep(1000);

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.prefs;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.util.JacksonMapper;
@@ -51,7 +51,7 @@ public class AppPrefsStorageHandler {
var read = o.readTree(Files.readAllBytes(file));
content = read.isObject() ? (ObjectNode) read : null;
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -152,7 +152,7 @@ public class AppPrefsStorageHandler {
}
return value;
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
return defaultObject;
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.prefs;
import io.xpipe.app.ext.PrefsValue;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.CommandSupport;
import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.Translatable;
@@ -35,7 +35,7 @@ public interface ExternalApplicationType extends PrefsValue {
try {
return findApp().isPresent();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return false;
}
}
@@ -74,7 +74,7 @@ public interface ExternalApplicationType extends PrefsValue {
pc.command(String.format("open -a \"%s.app\"", getApplicationName()))
.execute();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
@@ -94,7 +94,7 @@ public interface ExternalApplicationType extends PrefsValue {
try (ShellControl pc = LocalShell.getShell()) {
return CommandSupport.findProgram(pc, getExecutable()).isPresent();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return false;
}
}
@@ -102,7 +102,7 @@ public interface ExternalApplicationType extends PrefsValue {
default void launch(CommandBuilder args) throws Exception {
try (ShellControl pc = LocalShell.getShell()) {
if (!CommandSupport.isInPath(pc, getExecutable())) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IOException(
"Executable " + getExecutable()
+ " not found in PATH. Either add it to the PATH and refresh the environment by restarting XPipe, or specify an absolute executable path using the custom terminal setting."));
@@ -132,7 +132,7 @@ public interface ExternalApplicationType extends PrefsValue {
return out.map(filePath -> Path.of(filePath.toString()));
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().handle();
ErrorEventFactory.fromThrowable(ex).omit().handle();
}
return Optional.empty();
}
@@ -145,7 +145,7 @@ public interface ExternalApplicationType extends PrefsValue {
var name = this instanceof Translatable t
? t.toTranslatedString().getValue()
: getExecutable();
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new UnsupportedOperationException("Unable to find installation of " + name));
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.prefs;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.WindowsRegistry;
@@ -355,7 +355,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
public void launch(Path file) throws Exception {
var customCommand = AppPrefs.get().customEditorCommand().getValue();
if (customCommand == null || customCommand.isBlank()) {
throw ErrorEvent.expected(new IllegalStateException("No custom editor command specified"));
throw ErrorEventFactory.expected(new IllegalStateException("No custom editor command specified"));
}
var format =

View File

@@ -7,7 +7,7 @@ import io.xpipe.app.core.AppFontSizes;
import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.icon.SystemIconManager;
import io.xpipe.app.icon.SystemIconSource;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.*;
import io.xpipe.core.store.FilePath;
@@ -120,7 +120,7 @@ public class IconsCategory extends AppPrefsCategory {
var path = dir.get().asLocalPath();
if (Files.isRegularFile(path)) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalArgumentException(
"A custom icon source must be a directory containing .svg files, not a single file"));
}

View File

@@ -4,7 +4,7 @@ import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.base.*;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.*;
import java.io.IOException;
@@ -32,7 +32,7 @@ public class LoggingCategory extends AppPrefsCategory {
Files.createDirectories(dir);
DesktopHelper.browsePathLocal(dir);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
})
.disable(prefs.enableTerminalLogging.not())))

View File

@@ -8,7 +8,7 @@ import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.ext.ShellStore;
import io.xpipe.app.hub.comp.StoreChoiceComp;
import io.xpipe.app.hub.comp.StoreViewState;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.terminal.*;
@@ -51,7 +51,7 @@ public class TerminalCategory extends AppPrefsCategory {
});
feature.throwIfUnsupported();
} catch (LicenseRequiredException ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
}
});

View File

@@ -8,7 +8,7 @@ import io.xpipe.app.core.AppLogs;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.UserReportComp;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.DesktopHelper;
@@ -44,7 +44,7 @@ public class TroubleshootCategory extends AppPrefsCategory {
.spacer(19)
.addComp(
new TileButtonComp("reportIssue", "reportIssueDescription", "mdal-bug_report", e -> {
var event = ErrorEvent.fromMessage("User Report");
var event = ErrorEventFactory.fromMessage("User Report");
if (AppLogs.get().isWriteToFile()) {
event.attachment(AppLogs.get().getSessionLogsDirectory());
}

View File

@@ -5,7 +5,7 @@ import io.xpipe.app.comp.base.ModalOverlay;
import io.xpipe.app.core.AppFontSizes;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.*;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.XPipeInstallation;
@@ -63,7 +63,7 @@ public class WorkspaceCreationDialog {
DesktopHelper.browseFileInDirectory(file);
OperationMode.close();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}));
modal.show();

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.pwman;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.*;
import io.xpipe.core.process.CommandBuilder;
@@ -30,7 +30,7 @@ public class BitwardenPasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("Bitwarden CLI", "bw");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.link("https://bitwarden.com/help/cli/#download-and-install")
.handle();
return null;
@@ -70,7 +70,7 @@ public class BitwardenPasswordManager implements PasswordManager {
var password = login.required("password");
return new CredentialResult(user.isNull() ? null : user.asText(), InPlaceSecretValue.of(password.asText()));
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return null;
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.pwman;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.CommandSupport;
import io.xpipe.core.process.CommandBuilder;
@@ -30,7 +30,7 @@ public class DashlanePasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("Dashlane CLI", "dcli");
} catch (Exception e) {
ErrorEvent.fromThrowable(e).link("https://cli.dashlane.com/install").handle();
ErrorEventFactory.fromThrowable(e).link("https://cli.dashlane.com/install").handle();
return null;
}
@@ -57,7 +57,7 @@ public class DashlanePasswordManager implements PasswordManager {
login != null ? login.asText() : null,
password != null ? InPlaceSecretValue.of(password.asText()) : null);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return null;
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.pwman;
import io.xpipe.app.comp.base.ContextualFileReferenceChoiceComp;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.*;
import io.xpipe.core.process.CommandBuilder;
@@ -82,19 +82,19 @@ public class EnpassPasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("Enpass CLI", "enpass-cli");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.link("https://github.com/hazcod/enpass-cli")
.handle();
return null;
}
if (vaultPath == null) {
throw ErrorEvent.expected(new IllegalArgumentException("No vault path has been set"));
throw ErrorEventFactory.expected(new IllegalArgumentException("No vault path has been set"));
}
var vaultDir = vaultPath.asLocalPath();
if (!Files.exists(vaultDir)) {
throw ErrorEvent.expected(new IllegalArgumentException("Vault path " + vaultPath + " does not exist"));
throw ErrorEventFactory.expected(new IllegalArgumentException("Vault path " + vaultPath + " does not exist"));
}
if (Files.isRegularFile(vaultDir)) {
vaultDir = vaultDir.getParent();
@@ -133,7 +133,7 @@ public class EnpassPasswordManager implements PasswordManager {
}
if (json.size() == 0) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalArgumentException("No items were found matching the title " + key));
}
@@ -145,7 +145,7 @@ public class EnpassPasswordManager implements PasswordManager {
matches.add(title.asText());
}
});
throw ErrorEvent.expected(new IllegalArgumentException(
throw ErrorEventFactory.expected(new IllegalArgumentException(
"Ambiguous item name, multiple password entries match: " + String.join(", ", matches)));
}
@@ -155,7 +155,7 @@ public class EnpassPasswordManager implements PasswordManager {
!login.isEmpty() ? login : null, !secret.isEmpty() ? InPlaceSecretValue.of(secret) : null);
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return null;
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.pwman;
import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.*;
import io.xpipe.core.process.OsType;
@@ -71,7 +71,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
private static KeePassXcAssociationKey associate() throws IOException {
var found = findKeePassProxy();
if (found.isEmpty()) {
throw ErrorEvent.expected(new UnsupportedOperationException("No KeePassXC installation was found"));
throw ErrorEventFactory.expected(new UnsupportedOperationException("No KeePassXC installation was found"));
}
var c = new KeePassXcProxyClient(found.get());
@@ -106,7 +106,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
if (client == null) {
var found = findKeePassProxy();
if (found.isEmpty()) {
throw ErrorEvent.expected(new UnsupportedOperationException("No KeePassXC installation was found"));
throw ErrorEventFactory.expected(new UnsupportedOperationException("No KeePassXC installation was found"));
}
var c = new KeePassXcProxyClient(found.get());
@@ -120,7 +120,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
try {
c.testAssociation();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
c.useExistingAssociationKey(null);
cached = null;
}
@@ -152,7 +152,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
return switch (OsType.getLocal()) {
@@ -182,7 +182,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
}
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
yield Optional.empty();
}
@@ -194,7 +194,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
try {
return KeePassXcPasswordManager.receive(key);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return null;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.pwman;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.DocumentationLink;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.util.InPlaceSecretValue;
@@ -154,7 +154,7 @@ public class KeePassXcProxyClient {
var ex = new IllegalStateException(
"KeePassXC client did not respond. Is the browser integration enabled for your KeePassXC database?");
ErrorEvent.preconfigure(ErrorEvent.fromThrowable(ex).expected().documentationLink(DocumentationLink.KEEPASSXC));
ErrorEventFactory.preconfigure(ErrorEventFactory.fromThrowable(ex).expected().documentationLink(DocumentationLink.KEEPASSXC));
throw ex;
}
@@ -167,7 +167,7 @@ public class KeePassXcProxyClient {
public void testAssociation() throws IOException {
if (associationKey == null) {
// We need to do an association first
throw ErrorEvent.expected(new IllegalStateException("KeePassXC association failed or was cancelled"));
throw ErrorEventFactory.expected(new IllegalStateException("KeePassXC association failed or was cancelled"));
}
// Generate a nonce
@@ -201,7 +201,7 @@ public class KeePassXcProxyClient {
Map<String, Object> responseMap = jsonToMap(responseJson);
if (responseMap.containsKey("error")) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalStateException(responseMap.get("error").toString()));
}
@@ -259,7 +259,7 @@ public class KeePassXcProxyClient {
Map<String, Object> responseMap = jsonToMap(responseJson);
if (responseMap.containsKey("error")) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalStateException(responseMap.get("error").toString()));
}
@@ -276,11 +276,11 @@ public class KeePassXcProxyClient {
var tree = JacksonMapper.getDefault().readTree(message);
var count = tree.required("count").asInt();
if (count == 0) {
throw ErrorEvent.expected(new IllegalArgumentException("No password was found for specified key"));
throw ErrorEventFactory.expected(new IllegalArgumentException("No password was found for specified key"));
}
if (count > 1) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalArgumentException("Password key is ambiguous and returned multiple results"));
}
@@ -468,7 +468,7 @@ public class KeePassXcProxyClient {
Map<String, Object> responseMap = jsonToMap(responseJson);
if (responseMap.containsKey("error")) {
throw ErrorEvent.expected(
throw ErrorEventFactory.expected(
new IllegalStateException(responseMap.get("error").toString()));
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.pwman;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.CommandSupport;
import io.xpipe.app.util.SecretManager;
@@ -40,7 +40,7 @@ public class KeeperPasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("Keeper Commander CLI", "keeper");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.link("https://docs.keeper.io/en/keeperpam/commander-cli/commander-installation-setup")
.handle();
return null;
@@ -101,7 +101,7 @@ public class KeeperPasswordManager implements PasswordManager {
return new CredentialResult(login, password != null ? InPlaceSecretValue.of(password) : null);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return null;
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.pwman;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.terminal.TerminalLauncher;
import io.xpipe.app.util.*;
import io.xpipe.core.process.*;
@@ -30,7 +30,7 @@ public class LastpassPasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("LastPass CLI", "lpass");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.link("https://github.com/LastPass/lastpass-cli")
.handle();
return null;
@@ -68,7 +68,7 @@ public class LastpassPasswordManager implements PasswordManager {
matches.add(title.asText());
}
});
throw ErrorEvent.expected(new IllegalArgumentException(
throw ErrorEventFactory.expected(new IllegalArgumentException(
"Ambiguous item name, multiple password entries match: " + String.join(", ", matches)));
}
@@ -78,7 +78,7 @@ public class LastpassPasswordManager implements PasswordManager {
!username.isEmpty() ? username : null,
!password.isEmpty() ? InPlaceSecretValue.of(password) : null);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return null;
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.pwman;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.CommandSupport;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ShellControl;
@@ -29,7 +29,7 @@ public class OnePasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("1Password CLI", "op");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.expected()
.link("https://developer.1password.com/docs/cli/get-started/")
.handle();
@@ -55,7 +55,7 @@ public class OnePasswordManager implements PasswordManager {
username != null ? username.asText() : null,
password != null ? InPlaceSecretValue.of(password.asText()) : null);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return null;
}
}

View File

@@ -5,7 +5,7 @@ import io.xpipe.app.comp.base.IntegratedTextAreaComp;
import io.xpipe.app.core.AppFontSizes;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.ExternalApplicationHelper;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.*;
@@ -89,7 +89,7 @@ public class PasswordManagerCommand implements PasswordManager {
return InPlaceSecretValue.of(out);
} catch (Exception ex) {
ErrorEvent.fromThrowable("Unable to retrieve password with command " + cmd, ex)
ErrorEventFactory.fromThrowable("Unable to retrieve password with command " + cmd, ex)
.expected()
.handle();
return null;

View File

@@ -4,7 +4,7 @@ import io.xpipe.app.comp.base.SecretFieldComp;
import io.xpipe.app.comp.base.TextFieldComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.*;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ShellControl;
@@ -75,7 +75,7 @@ public class PsonoPasswordManager implements PasswordManager {
try {
CommandSupport.isInLocalPathOrThrow("Psono CLI", "psonoci");
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.expected()
.link("https://doc.psono.com/user/psonoci/install.html")
.handle();
@@ -103,7 +103,7 @@ public class PsonoPasswordManager implements PasswordManager {
username.isNull() ? null : username.asText(),
password.isNull() ? null : InPlaceSecretValue.of(password.asText()));
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
return null;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.pwman;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.LocalShell;
import io.xpipe.core.util.InPlaceSecretValue;
@@ -98,7 +98,7 @@ public class WindowsCredentialManager implements PasswordManager {
.readStdoutOrThrow();
return new CredentialResult(username, password.isEmpty() ? null : InPlaceSecretValue.of(password));
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().handle();
ErrorEventFactory.fromThrowable(ex).expected().handle();
return null;
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.rdp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.ExternalApplicationHelper;
import io.xpipe.app.prefs.ExternalApplicationType;
@@ -14,7 +14,7 @@ public class CustomRdpClient implements ExternalApplicationType, ExternalRdpClie
public void launch(RdpLaunchConfig configuration) throws Exception {
var customCommand = AppPrefs.get().customRdpClientCommand().getValue();
if (customCommand == null || customCommand.isBlank()) {
throw ErrorEvent.expected(new IllegalStateException("No custom RDP command specified"));
throw ErrorEventFactory.expected(new IllegalStateException("No custom RDP command specified"));
}
var format =

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.rdp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.util.WindowsRegistry;
@@ -31,7 +31,7 @@ public class DevolutionsRdpClient implements ExternalApplicationType.WindowsType
WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\rdm\\DefaultIcon");
return r.map(Path::of);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return Optional.empty();
}
}

View File

@@ -4,7 +4,7 @@ import io.xpipe.app.core.AppProperties;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.app.ext.NameableStore;
import io.xpipe.app.hub.comp.StoreSortMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.FixedHierarchyStore;
import io.xpipe.app.util.ThreadHelper;
@@ -452,7 +452,7 @@ public abstract class DataStorage {
if (throwOnFail) {
throw ex;
} else {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
return false;
}
} finally {

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.storage;
import io.xpipe.app.ext.UserScopeStore;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.EncryptionToken;
import io.xpipe.core.store.DataStore;
@@ -99,7 +99,7 @@ public class DataStorageNode {
var currentUser = secret.getEncryptedToken().isUser();
return new DataStorageNode(read, currentUser, true, true);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).build().handle();
ErrorEventFactory.fromThrowable(e).build().handle();
return fail();
}
}
@@ -114,7 +114,7 @@ public class DataStorageNode {
try (JsonGenerator g = f.createGenerator(writer).setPrettyPrinter(new DefaultPrettyPrinter())) {
JacksonMapper.getDefault().writeTree(g, node.getContentNode());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).build().handle();
ErrorEventFactory.fromThrowable(e).build().handle();
return node.getContentNode();
}

View File

@@ -4,7 +4,7 @@ import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.ext.NameableStore;
import io.xpipe.app.ext.UserScopeStore;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.*;
import io.xpipe.core.util.JacksonMapper;
@@ -299,7 +299,7 @@ public class DataStoreEntry extends StorageElement {
var fileNode = mapper.readTree(storeFile.toFile());
node = DataStorageNode.readPossiblyEncryptedNode(fileNode);
} catch (JacksonException ex) {
ErrorEvent.fromThrowable(ex).omit().expected().handle();
ErrorEventFactory.fromThrowable(ex).omit().expected().handle();
node = DataStorageNode.fail();
}
@@ -575,7 +575,7 @@ public class DataStoreEntry extends StorageElement {
try {
validateOrThrow();
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
}
@@ -608,7 +608,7 @@ public class DataStoreEntry extends StorageElement {
// Check whether we have a provider as well
DataStoreProviders.byStore(newStore);
} catch (Throwable e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
newStore = null;
}
@@ -647,7 +647,7 @@ public class DataStoreEntry extends StorageElement {
notifyUpdate(false, false);
lifecycleStore.initializeStore();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
} finally {
decrementBusyCounter();
notifyUpdate(false, false);
@@ -662,7 +662,7 @@ public class DataStoreEntry extends StorageElement {
notifyUpdate(false, false);
lifecycleStore.finalizeStore();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
} finally {
decrementBusyCounter();
notifyUpdate(false, false);

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.storage;
import io.xpipe.app.ext.DataStorageExtensionProvider;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.EncryptionKey;
@@ -59,7 +59,7 @@ public class StandardStorage extends DataStorage {
try {
FileUtils.forceMkdir(dir.toFile());
} catch (Exception e) {
ErrorEvent.fromThrowable("Unable to create vault directory", e)
ErrorEventFactory.fromThrowable("Unable to create vault directory", e)
.terminal(true)
.build()
.handle();
@@ -68,7 +68,7 @@ public class StandardStorage extends DataStorage {
try {
initSystemInfo();
} catch (Exception e) {
ErrorEvent.fromThrowable("Unable to load vault system info", e)
ErrorEventFactory.fromThrowable("Unable to load vault system info", e)
.build()
.handle();
}
@@ -78,7 +78,7 @@ public class StandardStorage extends DataStorage {
try {
dataStorageUserHandler.init();
} catch (IOException e) {
ErrorEvent.fromThrowable("Unable to load vault users", e)
ErrorEventFactory.fromThrowable("Unable to load vault users", e)
.terminal(true)
.build()
.handle();
@@ -98,7 +98,7 @@ public class StandardStorage extends DataStorage {
FileUtils.forceMkdir(categoriesDir.toFile());
FileUtils.forceMkdir(dataDir.toFile());
} catch (Exception e) {
ErrorEvent.fromThrowable("Unable to create vault directory", e)
ErrorEventFactory.fromThrowable("Unable to create vault directory", e)
.terminal(true)
.build()
.handle();
@@ -123,14 +123,14 @@ public class StandardStorage extends DataStorage {
directoriesToKeep.add(path);
} catch (Exception ex) {
// Data corruption and schema changes are expected
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
}
// Show one exception
if (exception.get() != null) {
ErrorEvent.fromThrowable(exception.get()).handle();
ErrorEventFactory.fromThrowable(exception.get()).handle();
}
setupBuiltinCategories();
@@ -169,13 +169,13 @@ public class StandardStorage extends DataStorage {
directoriesToKeep.add(path);
}
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
// Show one exception
if (exception.get() != null) {
ErrorEvent.fromThrowable(exception.get()).expected().handle();
ErrorEventFactory.fromThrowable(exception.get()).expected().handle();
}
storeEntriesSet.forEach(e -> {
@@ -190,7 +190,7 @@ public class StandardStorage extends DataStorage {
});
}
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).terminal(true).build().handle();
ErrorEventFactory.fromThrowable(ex).terminal(true).build().handle();
}
var hasFixedLocal = storeEntriesSet.stream()
@@ -204,7 +204,7 @@ public class StandardStorage extends DataStorage {
local.deleteFromDisk();
hasFixedLocal = false;
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex)
ErrorEventFactory.fromThrowable(ex)
.terminal(true)
.expected()
.build()
@@ -299,7 +299,7 @@ public class StandardStorage extends DataStorage {
try {
p.storageInit();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
}
});
}
@@ -354,7 +354,7 @@ public class StandardStorage extends DataStorage {
FileUtils.forceMkdir(getStoresDir().toFile());
FileUtils.forceMkdir(getCategoriesDir().toFile());
} catch (Exception e) {
ErrorEvent.fromThrowable(e)
ErrorEventFactory.fromThrowable(e)
.description("Unable to create storage directory " + getStoresDir())
.terminal(true)
.build()
@@ -374,7 +374,7 @@ public class StandardStorage extends DataStorage {
exception.set(ex);
} catch (Exception ex) {
// Data corruption and schema changes are expected
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
@@ -389,13 +389,13 @@ public class StandardStorage extends DataStorage {
} catch (Exception ex) {
// Data corruption and schema changes are expected
exception.set(ex);
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
// Show one exception
if (exception.get() != null) {
ErrorEvent.fromThrowable(exception.get()).expected().handle();
ErrorEventFactory.fromThrowable(exception.get()).expected().handle();
}
deleteLeftovers();
@@ -447,11 +447,11 @@ public class StandardStorage extends DataStorage {
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).terminal(true).build().handle();
ErrorEventFactory.fromThrowable(ex).terminal(true).build().handle();
}
// Delete leftover directories in categories dir
@@ -480,11 +480,11 @@ public class StandardStorage extends DataStorage {
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
ErrorEventFactory.fromThrowable(ex).expected().omit().build().handle();
}
});
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).terminal(true).build().handle();
ErrorEventFactory.fromThrowable(ex).terminal(true).build().handle();
}
}
@@ -502,7 +502,7 @@ public class StandardStorage extends DataStorage {
vaultKey = EncryptionKey.getVaultSecretKey(id);
}
} catch (Exception e) {
ErrorEvent.fromThrowable(
ErrorEventFactory.fromThrowable(
"Unable to load vault key file " + file + " to decrypt vault contents. Is it corrupted?", e)
.terminal(true)
.build()
@@ -515,7 +515,7 @@ public class StandardStorage extends DataStorage {
if (Files.exists(file)) {
var read = Files.readString(file);
if (!OsType.getLocal().getName().equals(read)) {
ErrorEvent.fromMessage(
ErrorEventFactory.fromMessage(
"This vault was originally created on a different system running " + read
+ ". Sharing connection information between systems directly might cause some problems."
+ " If you want to properly synchronize connection information across many systems, you can take a look into the git vault synchronization functionality in the settings.")

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.ExternalApplicationHelper;
import io.xpipe.app.prefs.ExternalApplicationType;
@@ -30,7 +30,7 @@ public class CustomTerminalType implements ExternalApplicationType, ExternalTerm
public void launch(TerminalLaunchConfiguration configuration) throws Exception {
var custom = AppPrefs.get().customTerminalCommand().getValue();
if (custom == null || custom.isBlank()) {
throw ErrorEvent.expected(new IllegalStateException("No custom terminal command specified"));
throw ErrorEventFactory.expected(new IllegalStateException("No custom terminal command specified"));
}
var format = custom.toLowerCase(Locale.ROOT).contains("$cmd") ? custom : custom + " $CMD";

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.terminal;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.util.CommandSupport;
import io.xpipe.app.util.LocalShell;
@@ -105,7 +105,7 @@ public interface KittyTerminalType extends ExternalTerminalType, TrackableTermin
try (ShellControl pc = LocalShell.getShell()) {
return CommandSupport.findProgram(pc, "kitty").isPresent();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return false;
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.terminal;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.CommandBuilder;
@@ -77,7 +77,7 @@ public class KonsoleTerminalType extends ExternalTerminalType.SimplePathType {
AppCache.update("konsoleInstanceOptionSet", true);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.util.*;
import io.xpipe.core.process.CommandBuilder;
@@ -34,7 +34,7 @@ public class MobaXTermTerminalType implements ExternalApplicationType.WindowsTyp
WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\mobaxterm\\DefaultIcon");
return r.map(Path::of);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return Optional.empty();
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.SshLocalBridge;
@@ -39,7 +39,7 @@ public class SecureCrtTerminalType implements ExternalApplicationType.WindowsTyp
return Optional.of(file);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return Optional.empty();
}
}

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.terminal;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreColor;
@@ -108,7 +108,7 @@ public class TerminalLaunchConfiguration {
var suffix = sc.getOsType() == OsType.MACOS
? "This command is available in the util-linux package which can be installed via homebrew."
: "This command is available in the util-linux package.";
throw ErrorEvent.expected(new IllegalStateException(
throw ErrorEventFactory.expected(new IllegalStateException(
"Logging requires the script command to be installed. " + suffix));
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.beacon.BeaconServerException;
@@ -46,7 +46,7 @@ public class TerminalLaunchRequest {
}
if (getResult() == null) {
throw ErrorEvent.expected(new BeaconServerException("Launch request aborted"));
throw ErrorEventFactory.expected(new BeaconServerException("Launch request aborted"));
}
var r = getResult();

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.terminal;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
@@ -143,7 +143,7 @@ public class TerminalLauncher {
throws Exception {
var type = AppPrefs.get().terminalType().getValue();
if (type == null) {
throw ErrorEvent.expected(new IllegalStateException(AppI18n.get("noTerminalSet")));
throw ErrorEventFactory.expected(new IllegalStateException(AppI18n.get("noTerminalSet")));
}
var color = entry != null ? DataStorage.get().getEffectiveColor(entry) : null;
@@ -213,7 +213,7 @@ public class TerminalLauncher {
var modMsg = ex.getMessage() != null && ex.getMessage().contains("Unable to find application named")
? ex.getMessage() + " in installed /Applications on this system"
: ex.getMessage();
throw ErrorEvent.expected(new IOException(
throw ErrorEventFactory.expected(new IOException(
"Unable to launch terminal " + type.toTranslatedString().getValue() + ": " + modMsg, ex));
}
}

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.util.ShellTemp;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialect;
@@ -45,7 +45,7 @@ public interface TerminalPrompt {
checkCanInstall(sc);
install(sc);
} catch (Exception e) {
ErrorEvent.fromThrowable(e).omit().handle();
ErrorEventFactory.fromThrowable(e).omit().handle();
return false;
}
return true;

View File

@@ -1,6 +1,6 @@
package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.ShellControl;
@@ -15,7 +15,7 @@ public class TerminalPromptManager {
try {
sc.withInitSnippet(p.terminalCommand());
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEventFactory.fromThrowable(e).handle();
}
}
}

View File

@@ -1,7 +1,7 @@
package io.xpipe.app.terminal;
import io.xpipe.app.ext.ShellStore;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
@@ -70,7 +70,7 @@ public class TerminalProxyManager {
matchingSession.getControl().start();
return Optional.of(matchingSession.getControl());
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
activeSession = new ActiveSession(uuid, null);
return Optional.empty();
}
@@ -84,7 +84,7 @@ public class TerminalProxyManager {
return control;
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
ErrorEventFactory.fromThrowable(ex).handle();
}
activeSession = new ActiveSession(uuid, null);
return Optional.empty();

Some files were not shown because too many files have changed in this diff Show More