X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FCollation%2FReading%2FWordForm.pm;h=9d27181f84f194dc8eae7279a538612be7bbe7e8;hb=a7f4020a1a1fd72aba6e25dc0a8f8aa9a1891202;hp=ebfa445ab80a3a288824df9ba490c4dca5a72a0f;hpb=f8862b584dcc04728d3bff48ea7c19cb9a078772;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Collation/Reading/WordForm.pm b/lib/Text/Tradition/Collation/Reading/WordForm.pm index ebfa445..9d27181 100644 --- a/lib/Text/Tradition/Collation/Reading/WordForm.pm +++ b/lib/Text/Tradition/Collation/Reading/WordForm.pm @@ -3,6 +3,8 @@ package Text::Tradition::Collation::Reading::WordForm; use Lingua::Features::Structure; use JSON (); use Moose; +use Text::Tradition::Error; +use TryCatch; =head1 NAME @@ -70,7 +72,12 @@ around BUILDARGS => sub { if( exists $args->{'JSON'} ) { my @data = split( / \/\/ /, $args->{'JSON'} ); # print STDERR "Attempting to parse " . $data[2] . " into structure"; - my $morph = Lingua::Features::Structure->from_string( $data[2] ); + my $morph; + try { + $morph = Lingua::Features::Structure->from_string( $data[2] ); + } catch { + throw("Could not parse string " . $data[2] . " into morphological structure"); + } $args = { 'language' => $data[0], 'lemma' => $data[1], 'morphology' => $morph }; } @@ -97,6 +104,13 @@ sub TO_JSON { $self->morphology->to_string() ); } +sub throw { + Text::Tradition::Error->throw( + 'ident' => 'Wordform error', + 'message' => $_[0], + ); +} + no Moose; __PACKAGE__->meta->make_immutable;