Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor: Effect.try calls map failures to typed errors #31217

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/31217/headmerged by juliusmarminge View on GitHub

Showing 62 changed files with 32 additions and 22 deletions (loading 59).

x
0 of 62 viewed, 62 left
4 additions and 1 deletionapps/desktop/src/app/DesktopCliCommand.tsModified
View file
@@ -140,7 +140,10 @@
const isExecutableFile = Effect.fn("DesktopCliCommand.isExecutableFile")(
function* (target: string) {
if ((yield* fs.stat(target)).type !== "File") return false;
- yield* Effect.tryPromise(() => NodeFSP.access(target, NodeFSP.constants.X_OK));
+ yield* Effect.tryPromise({
+ try: () => NodeFSP.access(target, NodeFSP.constants.X_OK),
+ catch: () => fail(`${target} is not executable.`),
+ });
return true;
Effect.orElseSucceed(() => false),
1 addition and 3 deletionsapps/desktop/src/electron/ElectronProtocol.tsModified
View file
@@ -216,9 +216,7 @@
if (request.method !== "GET" && request.method !== "HEAD") {
return new Response(null, { status: 405 });
- const pathname = yield* Effect.try(() => decodeURIComponent(url.pathname)).pipe(
- Effect.orElseSucceed(() => null),
- );
+ const pathname = Option.getOrNull(Option.liftThrowable(decodeURIComponent)(url.pathname));
if (pathname === null || pathname.includes("\0")) return new Response(null, { status: 400 });
const root = path.resolve(assetDirectory);
const assetPath = path.resolve(root, `.${pathname}`);
27 additions and 18 deletionsapps/desktop/src/ipc/methods/window.tsModified
View file