| @@ -4,6 +4,14 @@ import type { PlatformError } from "effect/PlatformError"; · 3 unmodified lines |
| 4 | 4 | import * as jsonc from "jsonc-parser"; |
| 5 | 5 | import type { SourceConfig, ExecutorFileConfig } from "./schema"; |
| 6 | 6 | |
| 7 | +export class ConfigWriteError { |
| 8 | + readonly _tag = "ConfigWriteError"; |
| 9 | + constructor( |
| 10 | + readonly path: string, |
| 11 | + readonly cause: unknown, |
| 12 | + ) {} |
| 13 | +} |
| 14 | + |
| 7 | 15 | const FORMATTING: jsonc.FormattingOptions = { |
| 8 | 16 | tabSize: 2, |
| 9 | 17 | insertSpaces: true, |
| @@ -118,13 +126,13 @@ export const removeSourceFromConfig = ( · 108 unmodified lines |
| 118 | 126 | export const writeConfig = ( |
| 119 | 127 | path: string, |
| 120 | 128 | config: ExecutorFileConfig, |
| 121 | | −): Effect.Effect<void, PlatformError, FileSystem.FileSystem> => |
| 129 | +): Effect.Effect<void, ConfigWriteError | PlatformError, FileSystem.FileSystem> => |
| 122 | 130 | Effect.gen(function* () { |
| 123 | 131 | const fs = yield* FileSystem.FileSystem; |
| 124 | 132 | const text = yield* Effect.try({ |
| 125 | 133 | try: () => JSON.stringify(config, null, 2) + "\n", |
| 126 | | − catch: (cause) => cause, |
| 127 | | − }).pipe(Effect.orDie); |
| 134 | + catch: (cause) => new ConfigWriteError(path, cause), |
| 135 | + }); |
| 128 | 136 | yield* fs.writeFileString(path, text); |
| 129 | 137 | }); |
| 130 | 138 | |