Clarify SSH IPC error presentation
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
1955084104
commit
477a96f9f7
2 files changed
+20
-5
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import {
|
||||
SshCommandSpawnError,
|
||||
SshCommandTimeoutError,
|
||||
SshHttpBridgeError,
|
||||
SshPasswordPromptError,
|
||||
} from "@t3tools/ssh/errors";
|
||||
@@ -22,7 +23,7 @@ import {
|
||||
DesktopSshEnvironmentRequestError,
|
||||
ensureSshEnvironment,
|
||||
fetchSshEnvironmentDescriptor,
|
||||
toDesktopSshOperationPresentationError,
|
||||
toDesktopSshIpcPresentationError,
|
||||
} from "./sshEnvironment.ts";
|
||||
import * as DesktopSshEnvironment from "../../ssh/DesktopSshEnvironment.ts";
|
||||
import * as DesktopSshPasswordPrompts from "../../ssh/DesktopSshPasswordPrompts.ts";
|
||||
@@ -102,12 +103,23 @@ describe("SSH environment IPC", () => {
|
||||
cause,
|
||||
});
|
||||
|
||||
const presentation = toDesktopSshOperationPresentationError(structured);
|
||||
const presentation = toDesktopSshIpcPresentationError(structured);
|
||||
assert.equal(structured.message, "Failed to spawn SSH command for devbox.");
|
||||
assert.equal(presentation.message, cause.message);
|
||||
assert.strictEqual(presentation.cause, structured);
|
||||
});
|
||||
|
||||
it("passes structural SSH errors without process causes through the IPC boundary", () => {
|
||||
const structured = new SshCommandTimeoutError({
|
||||
command: "ssh",
|
||||
argumentCount: 0,
|
||||
target: "devbox",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
|
||||
assert.strictEqual(toDesktopSshIpcPresentationError(structured), structured);
|
||||
});
|
||||
|
||||
it.effect("fetches and decodes the remote environment descriptor", () => {
|
||||
const requestUrls: string[] = [];
|
||||
const layer = makeHttpClientLayer((request) =>
|
||||
|
||||
@@ -73,7 +73,10 @@ const isSshCausePresentationError = Schema.is(
|
||||
]),
|
||||
);
|
||||
|
||||
export function toDesktopSshOperationPresentationError(
|
||||
// Electron only forwards the message from a rejected ipcRenderer.invoke promise. Keep the typed,
|
||||
// structural SSH error intact as the cause for main-process diagnostics while preserving the
|
||||
// actionable process message that the renderer historically presented to the user.
|
||||
export function toDesktopSshIpcPresentationError(
|
||||
error: DesktopSshEnvironment.DesktopSshEnvironmentOperationError,
|
||||
): DesktopSshEnvironment.DesktopSshEnvironmentOperationError | Error {
|
||||
if (isSshCausePresentationError(error) && error.cause instanceof Error) {
|
||||
@@ -169,7 +172,7 @@ export const ensureSshEnvironment = DesktopIpc.makeIpcMethod({
|
||||
)
|
||||
: Effect.fail(error),
|
||||
}),
|
||||
Effect.mapError(toDesktopSshOperationPresentationError),
|
||||
Effect.mapError(toDesktopSshIpcPresentationError),
|
||||
);
|
||||
}),
|
||||
});
|
||||
@@ -182,7 +185,7 @@ export const disconnectSshEnvironment = DesktopIpc.makeIpcMethod({
|
||||
const sshEnvironment = yield* DesktopSshEnvironment.DesktopSshEnvironment;
|
||||
yield* sshEnvironment
|
||||
.disconnectEnvironment(target)
|
||||
.pipe(Effect.mapError(toDesktopSshOperationPresentationError));
|
||||
.pipe(Effect.mapError(toDesktopSshIpcPresentationError));
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user