🌻 📖 Clang::CastXML::Exception

NAME

Clang::CastXML::Exception - Base exception class for Clang::CastXML

VERSION

version 0.02

SYNOPSIS

 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);

DESCRIPTION

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.

ROLES

This class consumes the Throwable and StackTrace::Auto roles.

METHODS

message

 my $message = $ex->message;

Get the message for the exception. This must be defined in the subclass.

to_string

 my $string = $ex->to_string;
 my $string = "$ex";

Generate the human readable string diagnostic for the exception.

SEE ALSO

Clang::CastXML

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

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.