Skip to content

Commit

Permalink
Add catch-all CompilerError that indicates which constant caused the …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
demsullivan committed Oct 23, 2023
1 parent 6dbdc29 commit 2df1496
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dry/typescript/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Compiler

param :mod, type: DryTypes.Instance(Module)

CompilerError = Class.new(StandardError)

def compile
@ts_to_dry_map = {}
namespace = build(mod)
Expand All @@ -29,6 +31,8 @@ def build(mod)
ts_type = AstParser.visit(constant.to_ast)
@ts_to_dry_map[ts_type] = constant
[ts_type.name || constant_name, ts_type]
rescue StandardError => e
raise CompilerError, "Error during build while processing constant #{constant_name}: #{e.message}"
end.to_h
end

Expand Down

0 comments on commit 2df1496

Please sign in to comment.