@@ -6,7 +6,8 @@ defmodule JS2E.Printer.ArrayPrinter do
66
77 require Elixir . { EEx , Logger }
88 alias JS2E.Printer
9- alias JsonSchema.Types
9+ alias JsonSchema . { Parser , Resolver , Types }
10+ alias Parser.ParserError
1011 alias Printer . { PrinterError , PrinterResult , Utils }
1112
1213 alias Types . { ArrayType , PrimitiveType , SchemaDefinition }
@@ -16,8 +17,7 @@ defmodule JS2E.Printer.ArrayPrinter do
1617 ElmEncoders ,
1718 ElmFuzzers ,
1819 ElmTypes ,
19- Naming ,
20- ResolveType
20+ Naming
2121 }
2222
2323 @ templates_location Application . get_env ( :js2e , :templates_location )
@@ -63,15 +63,18 @@ defmodule JS2E.Printer.ArrayPrinter do
6363 _module_name
6464 ) do
6565 with { :ok , { items_type , _resolved_schema_def } } <-
66- ResolveType . resolve_type ( items_path , path , schema_def , schema_dict ) ,
66+ Resolver . resolve_type ( items_path , path , schema_def , schema_dict ) ,
6767 { :ok , items_type_name } <- determine_type_name ( items_type ) ,
6868 { :ok , items_decoder_name } <- determine_decoder_name ( items_type ) do
6969 "#{ Naming . normalize_identifier ( name , :downcase ) } Decoder"
7070 |> decoder_template ( items_type_name , items_decoder_name )
7171 |> PrinterResult . new ( )
7272 else
73- { :error , error } ->
74- PrinterResult . new ( "" , [ error ] )
73+ { :error , % ParserError { identifier: id , error_type: atom , message: str } } ->
74+ PrinterResult . new ( "" , [ PrinterError . new ( id , atom , str ) ] )
75+
76+ { :error , printer_error } ->
77+ PrinterResult . new ( "" , [ printer_error ] )
7578 end
7679 end
7780
@@ -135,15 +138,18 @@ defmodule JS2E.Printer.ArrayPrinter do
135138 _module_name
136139 ) do
137140 with { :ok , { items_type , _resolved_schema_def } } <-
138- ResolveType . resolve_type ( items_path , path , schema_def , schema_dict ) ,
141+ Resolver . resolve_type ( items_path , path , schema_def , schema_dict ) ,
139142 { :ok , items_type_name } <- determine_type_name ( items_type ) ,
140143 { :ok , items_encoder_name } <- determine_encoder_name ( items_type ) do
141144 "encode#{ Naming . normalize_identifier ( items_type_name , :upcase ) } s"
142145 |> encoder_template ( name , items_type_name , items_encoder_name )
143146 |> PrinterResult . new ( )
144147 else
145- { :error , error } ->
146- PrinterResult . new ( "" , [ error ] )
148+ { :error , % ParserError { identifier: id , error_type: atom , message: str } } ->
149+ PrinterResult . new ( "" , [ PrinterError . new ( id , atom , str ) ] )
150+
151+ { :error , printer_error } ->
152+ PrinterResult . new ( "" , [ printer_error ] )
147153 end
148154 end
149155
@@ -192,7 +198,7 @@ defmodule JS2E.Printer.ArrayPrinter do
192198 _module_name
193199 ) do
194200 with { :ok , { items_type , _resolved_schema_def } } <-
195- ResolveType . resolve_type ( items_path , path , schema_def , schema_dict ) ,
201+ Resolver . resolve_type ( items_path , path , schema_def , schema_dict ) ,
196202 { :ok , items_type_name } <- determine_type_name ( items_type ) ,
197203 { :ok , items_fuzzer_name } <- determine_fuzzer_name ( items_type ) do
198204 array_name = Naming . normalize_identifier ( name , :upcase )
@@ -213,8 +219,11 @@ defmodule JS2E.Printer.ArrayPrinter do
213219 )
214220 |> PrinterResult . new ( )
215221 else
216- { :error , error } ->
217- PrinterResult . new ( "" , [ error ] )
222+ { :error , % ParserError { identifier: id , error_type: atom , message: str } } ->
223+ PrinterResult . new ( "" , [ PrinterError . new ( id , atom , str ) ] )
224+
225+ { :error , printer_error } ->
226+ PrinterResult . new ( "" , [ printer_error ] )
218227 end
219228 end
220229
0 commit comments