Config-Model

 view release on metacpan or  search on metacpan

lib/Config/Model/Exception.pm  view on Meta::CPAN

sub full_message {
    my $self = shift;

    my $obj = $self->object;

    my $msg = '';
    $msg .= "In function " . $self->function . ": "
        if defined $self->function;

    my $type = $self->expected_type;

    $msg .=
          $self->description
        . " for element '"
        . $obj->location
        . "'\n\tgot type '"
        . $self->got_type
        . "', expected '"
        .  (ref $type ? join("' or '",@$type) : $type) . "' "
        . $self->info . "\n";

    return $msg;
}

package Config::Model::Exception::ConfigFile 2.163;

use Mouse;
extends 'Config::Model::Exception::User';

sub _desc {
    return 'error in configuration file' ;
}

package Config::Model::Exception::ConfigFile::Missing 2.163;

use Mouse;
use Mouse::Util::TypeConstraints;

extends 'Config::Model::Exception::ConfigFile';

sub _desc {
    return 'missing configuration file';
}

subtype 'ExcpPathTiny', as 'Object', where {$_->isa('Path::Tiny')} ;

has file => (is => 'rw', isa => 'Str | ExcpPathTiny' );

sub full_message {
    my $self = shift;

    return "Error: cannot find configuration file " . $self->file . "\n";
}

package Config::Model::Exception::Formula 2.163;

use Mouse;
extends 'Config::Model::Exception::Model';

sub _desc {
    return 'error in computation formula of the configuration model';
}

package Config::Model::Exception::Internal 2.163;

use Mouse;
extends 'Config::Model::Exception::Fatal';

sub _desc {
    return 'internal error' ;
}

1;

# ABSTRACT: Exception mechanism for configuration model

__END__

=pod

=encoding UTF-8

=head1 NAME

Config::Model::Exception - Exception mechanism for configuration model

=head1 VERSION

version 2.163

=head1 SYNOPSIS

  use  Config::Model::Exception;

  # later
  my $kaboom = 1;
  Config::Model::Exception::Model->throw(
      error  => "Went kaboom",
      object => $self
  ) if $kaboom;

=head1 DESCRIPTION

This module creates exception classes used by L<Config::Model>.

All exception class name begins with C<Config::Model::Exception>

The exception classes are:

=over

=item C<Config::Model::Exception>

Base class. It accepts an C<object> argument. The user must pass the
reference of the object where the exception occurred. The object name
is used to generate the error message.

=back

  TODO: list all exception classes and hierarchy. 



( run in 0.536 second using v1.01-cache-2.11-cpan-d7f47b0818f )