Subject: | Make constraint failure errors look less like data dumps |
With complex types the error message on constraint failure also gets complex:
{"featured_listing_id" => 0,"inflate_via" => "pg","inflate_with" => {"with_age" => 1,"with_formatted_attributes" => "list","with_mls_board" => 'FaceBookApp::Model::Corp::MlsBoard=HASH(0xc3c2908)',"with_status" => '14',"with_type" => '4'},"page_number" => 1,"rows_per_page" => 10,"search_criteria" => bless( {"mls_board_id" => 70,"search_images_count_min" => 1,"search_mls_area_ids" => 'ARRAY(0xa478c00)',"search_mls_boards_mls_type_ids" => 'ARRAY(0xa4794a0)'}, 'TigerLead::MLS::ListingSearch::Criteria' ),"search_via" => "es","sort_order" => "price"} did not pass type constraint "Dict[inflate_via=>Maybe[StrMatch[(?-xism:^(?:es|pg)$)]],inflate_with=>Maybe[HashRef],page_number=>PageNumberType,rows_per_page=>Int2_not_negative,search_criteria=>Ref,search_via=>Maybe[StrMatch[(?-xism:^(?:es|pg)$)]],sort_order=>Str]" (in $SLURPY) at foo.pm line 95.
My issue is that the key "did not pass type constraint" text is 'lost' in all those details.
The details are very helpful so I don't want to loose them, but the error message looks like a simple debug data dump.
I would like to find a way to make it look less like a debug data dump.
I suggest simply adding the prefix "The value " to the message:
The value {"featured_listing_id" => 0,"inflate_via" => "pg","inflate_with" => {"with_age" => 1,"with_formatted_attributes" => "list","with_mls_board" => 'FaceBookApp::Model::Corp::MlsBoard=HASH(0xc3c2908)',"with_status" => '14',"with_type" => '4'},"page_number" => 1,"rows_per_page" => 10,"search_criteria" => bless( {"mls_board_id" => 70,"search_images_count_min" => 1,"search_mls_area_ids" => 'ARRAY(0xa478c00)',"search_mls_boards_mls_type_ids" => 'ARRAY(0xa4794a0)'}, 'TigerLead::MLS::ListingSearch::Criteria' ),"search_via" => "es","sort_order" => "price"} did not pass type constraint "Dict[inflate_via=>Maybe[StrMatch[(?-xism:^(?:es|pg)$)]],inflate_with=>Maybe[HashRef],page_number=>PageNumberType,rows_per_page=>Int2_not_negative,search_criteria=>Ref,search_via=>Maybe[StrMatch[(?-xism:^(?:es|pg)$)]],sort_order=>Str]" (in $SLURPY) at foo.pm line 95.
that simple change immediately clues the reader that there's a sentence here so they know to make the effort to read it.