Failing Early
use Your::Point; my $point = Your::Point->new( x => 10, );
Error Thrown:
your.point error - No value specified for y
Thus Spake Andy:
If you then forget to provide an x
or y
value then you'll get an
error thrown. Fail early. Fail often. The error is thrown as a
Badger::Exception
object. This has an error type which defaults to a
dotted string based on the module that threw it (e.g. Your::Point
throws
your.point
). You can use this to match different error types. It is
assumed to be hierarchical, so that you can catch all database
errors,
for example, and that would include more specified exception types like
database.connector
and database.query
, for example. The other part of
the exception is the error message for human consumption. The exception
object has an auto-stringification method so that you can simply print it
and see the type/message summary.