Subject: | error handling in Brick::Results->flatten_by_field() |
I am, as of yet, unable to reproduce this, but something in the
processing of input against a profile seems to be generating a result
hash with some odd contents. Most recently, I ran into a situation where
an error entry pointed to a coderef rather than a hashref. This creates
a problem because the code that goes through each error entry checks to
see if it's a ref or not, and not that it's specifically a hashref. This
means that if it's some other kind of reference (coderef, arrayref) it
will get through the unless block, but die fatally when it encounters an
attempt to dereference it as a hash.
For now, I've replaced this:
# is it a single error or a composition?
unless( ref $hash )
{
next;
}
with this:
# is it a single error or a composition?
if ( not ref $hash ) {
next;
}
elsif ( ref $hash ne 'HASH' ) {
use Data::Dump::Streamer;
croak "encountered unexpected result: ", Dump($hash);
}
in an attempt to help me maintain my sanity. I'm going to work on
reproducing this problem, but I wanted to log this before I lost track
of it. It strikes me that better error checking needs to happen either
here or in the building of the result hash, or both.