RoPkg::Exceptions - exceptions used by RoPkg packages
RoPkg::Exceptions is a collection of predefined exceptions used by
all modules from RoPkg namespace.
#!/usr/bin/perl
use strict;
use warnings;
use RoPkg::Exceptions;
sub main {
eval {
if ( $#ARGV == -1 ) {
Param::Missing->throw('No parameter found');
}
};
if ( my $e = Exception::Class->caught('Param::Missing') ) {
print STDERR $e->message,$/,$e->trace,$/;
}
}
main();
It is very possible that you don't find a good reason for using
exceptions from this example. And you are right. This example is kind of
silly. But, try to use exceptions in a real project. Then, you will
apreciate their real value.
RoPkg::Exceptions require perl 5.008 or later and the
Exception::Class module.
The following exceptions are defined in this class:
- *) General - general pourpose exception
- *) OutsideClass - raised when a method is called outside a class
instance
- *) File - the base for all file related exceptions . This exception has
the filename parameter, who can be used to specify the path to the
file. filename parameter can be used by all derivated exceptions. The
following exceptions are derivated from File:
- *) File::NotFound - the file was not found
- *) File::Open - error while opening file
- *) File::Create - could not create file
- *) Dir - the base for all directory related exceptions . This exception
has the dirname parameter, who can be used to specify the path to the
directory. dirname parameter can be used by all derivated exceptions.
The following exceptions are derivated from Dir:
- *) Dir::NotFound - the directory was not found
- *) Dir::Open - error while opening directory
- *) Dir::Create - could not create directory
- *) Param - the base for all parameters related exceptions. This exception
has the name parameter, who can be used to specify the parameter
name. name can be used by all derivated exceptions. The following
exceptions are derivated from Param:
- *) Param::Missing - the parameter was not found
- *) Param::Unknown - the parameter is unknown
- *) Param::Wrong - the parameter has the wrong value or is not defined
- *) DB - the base for all database related exceptions. This exception has
the following parameters: dsn, user and pass . This
exception (and the ones derivated from her) are mostly used in RoPkg::DB
class. Of course, this doesn't means that you can't use them in your
application ;) .The following exceptions are derivated from DB:
- *) DB::Connect - raised when the connection with the database could not be
established
- *) DB::ConnExists - raised when a connection with the same name already
exists.
- *) DB::ConnNotFound - the requested connection was not found
- *) DB::NoResults - the sql query returned no results
Subredu Manuel <diablo@iasi.roedu.net>
The current version is 0.2.1
The tests for this module are located in t directory. To
run those tests, use the following command: make test
This module does not have any public methods.
This module is perl critic level 1 compliant with 1 exception.
No known bugs. If you find one (or many) please send me a detailed
report.
No configuration file or environment variables are used by this
module.
Copyright (C) 2005 Subredu Manuel. All Rights Reserved. This
module is free software; you can redistribute it and/or modify it under the
same terms as Perl itself. The LICENSE file contains the full text of the
license.