@@ -9,6 +9,8 @@ import * as yaml from "js-yaml"
99import path from "path"
1010import { RunCommandService } from "./os-command.js"
1111
12+ export class GistError extends Data . TaggedError ( "GistError" ) < { message : string } > { }
13+
1214//
1315//
1416// Schemas
@@ -272,8 +274,9 @@ class GHGistService extends Effect.Service<GHGistService>()("GHGistService", {
272274 } ,
273275 ( _ , company ) =>
274276 _ . pipe (
275- Effect . catchTag ( "GistCacheNotFound" , ( ) =>
276- Effect . gen ( function * ( ) {
277+ Effect . catchTag (
278+ "GistCacheNotFound" ,
279+ Effect . fnUntraced ( function * ( ) {
277280 yield * Effect . logInfo ( "Cache gist not found, creating new cache..." )
278281
279282 yield * runGetStringSuppressed (
@@ -282,12 +285,14 @@ class GHGistService extends Effect.Service<GHGistService>()("GHGistService", {
282285
283286 // retry loading the cache after creating it
284287 return yield * loadGistCache ( company , { recCache : true } )
285- } ) )
288+ } )
289+ )
286290 ) ,
287291 ( _ , company ) =>
288292 _ . pipe (
289- Effect . catchTag ( "GistCacheOfCompanyNotFound" , ( e ) =>
290- Effect . gen ( function * ( ) {
293+ Effect . catchTag (
294+ "GistCacheOfCompanyNotFound" ,
295+ Effect . fnUntraced ( function * ( e ) {
291296 yield * Effect . logInfo ( `Cache for company ${ company } not found, creating company-specific cache file...` )
292297
293298 yield * runGetStringSuppressed (
@@ -296,7 +301,8 @@ class GHGistService extends Effect.Service<GHGistService>()("GHGistService", {
296301
297302 // retry loading the cache after creating it
298303 return yield * loadGistCache ( company , { recCacheCompany : true } )
299- } ) )
304+ } )
305+ )
300306 )
301307 )
302308
@@ -501,7 +507,7 @@ class GHGistService extends Effect.Service<GHGistService>()("GHGistService", {
501507
502508 const isLogged = yield * runGetExitCode ( `echo ${ token } | gh auth login --with-token` ) . pipe ( Effect . orDie )
503509 if ( isLogged !== 0 ) {
504- return yield * Effect . fail ( new Error ( "Failed to log in to GitHub CLI with provided token" ) )
510+ return yield * new GistError ( { message : "Failed to log in to GitHub CLI with provided token" } )
505511 } else {
506512 yield * Effect . logInfo ( "Successfully logged in to GitHub CLI" )
507513 }
@@ -629,7 +635,7 @@ export class GistHandler extends Effect.Service<GistHandler>()("GistHandler", {
629635
630636 const configExists = yield * fs . exists ( YAMLPath )
631637 if ( ! configExists ) {
632- return yield * Effect . fail ( new Error ( `Configuration file not found: ${ YAMLPath } ` ) )
638+ return yield * new GistError ( { message : `Configuration file not found: ${ YAMLPath } ` } )
633639 }
634640
635641 const configFromYaml = yield * pipe (
@@ -671,22 +677,20 @@ export class GistHandler extends Effect.Service<GistHandler>()("GistHandler", {
671677
672678 const filesOnDiskWithFullPath = yield * Effect
673679 . all (
674- files_with_name . map ( ( f ) =>
675- Effect . gen ( function * ( ) {
676- const fullPath = path . join ( configFromYaml . settings . base_directory , f . path )
677- const fileExists = yield * fs . exists ( fullPath )
678-
679- if ( ! fileExists ) {
680- yield * Effect . logWarning ( `File not found: ${ fullPath } , skipping...` )
681- return Option . none ( )
682- }
683-
684- return Option . some ( {
685- path : fullPath ,
686- name : f . name
687- } )
680+ files_with_name . map ( Effect . fnUntraced ( function * ( f ) {
681+ const fullPath = path . join ( configFromYaml . settings . base_directory , f . path )
682+ const fileExists = yield * fs . exists ( fullPath )
683+
684+ if ( ! fileExists ) {
685+ yield * Effect . logWarning ( `File not found: ${ fullPath } , skipping...` )
686+ return Option . none ( )
687+ }
688+
689+ return Option . some ( {
690+ path : fullPath ,
691+ name : f . name
688692 } )
689- ) ,
693+ } ) ) ,
690694 {
691695 concurrency : "unbounded"
692696 }
0 commit comments