From 2df149638843b1d9d0f77a78aabf85bc999e1656 Mon Sep 17 00:00:00 2001 From: Dave Sullivan Date: Mon, 23 Oct 2023 12:08:02 -0400 Subject: [PATCH] Add catch-all CompilerError that indicates which constant caused the error --- lib/dry/typescript/compiler.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/dry/typescript/compiler.rb b/lib/dry/typescript/compiler.rb index 315cf18..d8a1d0a 100644 --- a/lib/dry/typescript/compiler.rb +++ b/lib/dry/typescript/compiler.rb @@ -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) @@ -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