Clang::CastXML::Exception - Base exception class for Clang::CastXML
version 0.02
package Clang::CastXML::Exception::MyException { use Moose; extends 'Clang::CastXML::Exception'; has x => ( is => 'ro' ); sub message { my($self) = @_; sprintf "oops error with x = %d", $self->x; } } # dies with an object expression tha stringifies to # "oops error with x = 1 at xxx.pl line xxx" Clang::CastXML::Exception::MyException->throw( x => 1);
This is the base class for exceptions thrown by Clang::CastXML. It keeps track of the stack where the exception is thrown, and stringifies to a useful message. Subclasses may add appropriate properties, and must define a message method that generates the exception message.
This class consumes the Throwable and StackTrace::Auto roles.
my $message = $ex->message;
Get the message for the exception. This must be defined in the subclass.
my $string = $ex->to_string; my $string = "$ex";
Generate the human readable string diagnostic for the exception.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2020 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.