@@ -7,7 +7,7 @@ def self.included(base)
77 end
88
99 def parser_error! ( comment )
10- self . class . parser_error! ( name , comment )
10+ raise Floe :: InvalidWorkflowError , " #{ self . class . location_name_str ( name ) } #{ comment } "
1111 end
1212
1313 def missing_field_error! ( field_name )
@@ -18,6 +18,16 @@ def invalid_field_error!(field_name, field_value = nil, comment = nil)
1818 self . class . invalid_field_error! ( name , field_name , field_value , comment )
1919 end
2020
21+ def runtime_field_error! ( field_name , field_value , comment )
22+ raise Floe ::ExecutionError , self . class . field_error_text ( name , field_name , field_value , comment )
23+ end
24+
25+ def wrap_runtime_error ( field_name , field_value )
26+ yield
27+ rescue Floe ::PathError => e
28+ runtime_field_error! ( field_name , field_value , e . message )
29+ end
30+
2131 def workflow_state? ( field_value , workflow )
2232 workflow . payload [ "States" ] ? workflow . payload [ "States" ] . include? ( field_value ) : true
2333 end
@@ -29,20 +39,25 @@ def wrap_parser_error(field_name, field_value)
2939 end
3040
3141 module ClassMethods
32- def parser_error! ( name , comment )
33- name = name . join ( "." ) if name . kind_of? ( Array )
34- raise Floe ::InvalidWorkflowError , "#{ name } #{ comment } "
42+ def location_name_str ( name )
43+ name . kind_of? ( Array ) ? name . join ( "." ) : name
3544 end
3645
46+ # these are here for State.build!
47+
3748 def missing_field_error! ( name , field_name )
38- parser_error! ( name , "does not have required field \" #{ field_name } \" " )
49+ raise Floe :: InvalidWorkflowError , "#{ location_name_str ( name ) } does not have required field \" #{ field_name } \" "
3950 end
4051
4152 def invalid_field_error! ( name , field_name , field_value , comment )
53+ raise Floe ::InvalidWorkflowError , field_error_text ( name , field_name , field_value , comment )
54+ end
55+
56+ def field_error_text ( name , field_name , field_value , comment = nil )
4257 # instead of displaying a large hash or array, just displaying the word Hash or Array
4358 field_value = field_value . class if field_value . kind_of? ( Hash ) || field_value . kind_of? ( Array )
4459
45- parser_error! ( name , " field \" #{ field_name } \" #{ " value \" #{ field_value } \" " unless field_value . nil? } #{ comment } ")
60+ " #{ location_name_str ( name ) } field \" #{ field_name } \" #{ " value \" #{ field_value } \" " unless field_value . nil? } #{ comment } "
4661 end
4762 end
4863 end
0 commit comments