@@ -444,15 +444,15 @@ export class ConfigLoader {
444444 } catch ( error : any ) {
445445 if ( error . code === "ENOENT" ) {
446446 // File not found - this is handled upstream, but provide clear error if called directly
447- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
447+ throw new ConfigError (
448448 `Configuration file not found: ${ filePath } ` ,
449449 "The file does not exist" ,
450450 [ "Run 'lab init' to create a configuration file" ] ,
451451 filePath ,
452452 ) ;
453453 } else if ( error . code === "EACCES" ) {
454454 // Permission denied - provide actionable solutions
455- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
455+ throw new ConfigError (
456456 `Cannot read configuration file: ${ filePath } ` ,
457457 "Permission denied - insufficient file permissions" ,
458458 [
@@ -464,7 +464,7 @@ export class ConfigLoader {
464464 ) ;
465465 } else if ( error . code === "ENOTDIR" ) {
466466 // Path component is not a directory
467- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
467+ throw new ConfigError (
468468 `Invalid path to configuration file: ${ filePath } ` ,
469469 "A component in the path is not a directory" ,
470470 [
@@ -476,7 +476,7 @@ export class ConfigLoader {
476476 }
477477
478478 // Re-throw unexpected errors with additional context
479- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
479+ throw new ConfigError (
480480 `Failed to access configuration file: ${ filePath } ` ,
481481 `System error: ${ error . message } ` ,
482482 [
@@ -507,7 +507,7 @@ export class ConfigLoader {
507507
508508 // Check for empty file (common user error)
509509 if ( ! fileContent . trim ( ) ) {
510- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
510+ throw new ConfigError (
511511 `Configuration file is empty: ${ filePath } ` ,
512512 "The file contains no content or only whitespace" ,
513513 [
@@ -529,7 +529,7 @@ export class ConfigLoader {
529529 // Validate that result is an object (not null, string, array, etc.)
530530 if ( ! parsed || typeof parsed !== "object" || Array . isArray ( parsed ) ) {
531531 const actualType = Array . isArray ( parsed ) ? "array" : typeof parsed ;
532- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
532+ throw new ConfigError (
533533 `Invalid configuration structure in ${ filePath } ` ,
534534 `Configuration must be a YAML object, but got ${ actualType } ` ,
535535 [
@@ -544,7 +544,7 @@ export class ConfigLoader {
544544 // Basic structure validation - ensure required 'types' field exists
545545 const config = parsed as any ;
546546 if ( ! Array . isArray ( config . types ) ) {
547- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
547+ throw new ConfigError (
548548 `Missing required 'types' field in ${ filePath } ` ,
549549 "Configuration must include a 'types' array defining commit types" ,
550550 [
@@ -565,7 +565,7 @@ export class ConfigLoader {
565565 // Extract line and column information if available
566566 if ( mark ) {
567567 const lineInfo = `line ${ mark . line + 1 } , column ${ mark . column + 1 } ` ;
568- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
568+ throw new ConfigError (
569569 `Invalid YAML syntax in ${ filePath } at ${ lineInfo } ` ,
570570 `Parsing error: ${ message } ` ,
571571 [
@@ -578,7 +578,7 @@ export class ConfigLoader {
578578 ) ;
579579 } else {
580580 // YAML error without specific location
581- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
581+ throw new ConfigError (
582582 `Invalid YAML syntax in ${ filePath } ` ,
583583 `Parsing error: ${ message } ` ,
584584 [
@@ -599,7 +599,7 @@ export class ConfigLoader {
599599
600600 // Handle file system errors that might occur during reading
601601 if ( error . code === "EISDIR" ) {
602- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
602+ throw new ConfigError (
603603 `Cannot read configuration: ${ filePath } is a directory` ,
604604 "Expected a file but found a directory" ,
605605 [
@@ -611,7 +611,7 @@ export class ConfigLoader {
611611 }
612612
613613 // Generic error fallback with context
614- throw new ( Error as any ) ( // TODO: Use proper ConfigError import
614+ throw new ConfigError (
615615 `Failed to parse configuration file: ${ filePath } ` ,
616616 `Unexpected error: ${ error . message } ` ,
617617 [
@@ -643,7 +643,7 @@ export class ConfigLoader {
643643
644644 // Handle common file system errors with specific guidance
645645 if ( error . code === "ENOENT" ) {
646- return new ( Error as any ) ( // TODO: Use proper ConfigError import
646+ return new ConfigError (
647647 `No configuration found starting from ${ context } ` ,
648648 "Could not locate a labcommitr configuration file in the project" ,
649649 [
@@ -655,7 +655,7 @@ export class ConfigLoader {
655655 }
656656
657657 if ( error . code === "EACCES" ) {
658- return new ( Error as any ) ( // TODO: Use proper ConfigError import
658+ return new ConfigError (
659659 `Permission denied while searching for configuration` ,
660660 `Cannot access directory or file: ${ error . path || context } ` ,
661661 [
@@ -667,7 +667,7 @@ export class ConfigLoader {
667667 }
668668
669669 if ( error . code === "ENOTDIR" ) {
670- return new ( Error as any ) ( // TODO: Use proper ConfigError import
670+ return new ConfigError (
671671 `Invalid directory structure encountered` ,
672672 `Expected directory but found file: ${ error . path || context } ` ,
673673 [
@@ -679,7 +679,7 @@ export class ConfigLoader {
679679
680680 // Handle YAML-related errors (these should typically be caught upstream)
681681 if ( error instanceof yaml . YAMLException ) {
682- return new ( Error as any ) ( // TODO: Use proper ConfigError import
682+ return new ConfigError (
683683 `Configuration file contains invalid YAML syntax` ,
684684 `YAML parsing error: ${ error . message } ` ,
685685 [
@@ -692,7 +692,7 @@ export class ConfigLoader {
692692
693693 // Handle timeout errors (e.g., from slow file systems)
694694 if ( error . code === "ETIMEDOUT" ) {
695- return new ( Error as any ) ( // TODO: Use proper ConfigError import
695+ return new ConfigError (
696696 `Timeout while accessing configuration files` ,
697697 "File system operation took too long to complete" ,
698698 [
@@ -709,7 +709,7 @@ export class ConfigLoader {
709709 ? `\n\nTechnical details:\n${ error . stack } `
710710 : "" ;
711711
712- return new ( Error as any ) ( // TODO: Use proper ConfigError import
712+ return new ConfigError (
713713 `Configuration loading failed` ,
714714 `${ errorMessage } ${ errorContext } ` ,
715715 [
0 commit comments