view release on metacpan or search on metacpan
t/01-basic.t view on Meta::CPAN
# Check we get an error message on missing input parameters
my $reporter;
can_ok ('App::CPRReporter', qw(employees certificates run));
throws_ok { $reporter = App::CPRReporter->new() } qr/Attribute .+ is required/, "Checking missing parameters";
throws_ok { $reporter = App::CPRReporter->new(employees => 't/stim/missing_file.xlsx', certificates => 't/stim/missing_file.xml', course => 't/stim/missing_file.xlsx') } qr/File does not exist.+/, "Checking missing xml file";
# Check we get the expected carps when we create the app on the stimulus test data
#warnings_like { $reporter = App::CPRReporter->new(employees => 't/stim/employees.xlsx', certificates => 't/stim/certificates.xml', course => 't/stim/course.xlsx') }
# { carped => qr/Oops: employee 'MAJOR LAZER' not found/},
# "On test data we should carp some warnings";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/CSVUtils.pm view on Meta::CPAN
A => { summary => 'Shortcut for --exclude-field-pat=.*, effectively excluding all fields', is_flag=>1, code => sub { $_[0]{exclude_field_pat} = '.*' } },
},
tags => ['category:field-selection'],
},
ignore_unknown_fields => {
summary => 'When unknown fields are specified in --include-field (--field) or --exclude-field options, ignore them instead of throwing an error',
schema => 'bool*',
},
show_selected_fields => {
summary => 'Show selected fields and then immediately exit',
schema => 'true*',
lib/App/CSVUtils.pm view on Meta::CPAN
util_args => \%util_args,
name => $name,
};
# inside the main eval block, we call hook handlers. A handler can
# throw an exception (which can be a string or an enveloped response
# like [500, "some error message"], see Rinci::function). we trap
# the exception so we can return the appropriate enveloped response.
MAIN_EVAL:
eval {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
1;
}
=item I<show_fatal_error($message)>
Like L</show_warning>, but throws an exception after displaying
$message.
=cut
sub show_fatal_error {
view all matches for this distribution
view release on metacpan or search on metacpan
t/initializr/process_zip.t view on Meta::CPAN
note( "zip setup and safely check tests" );
is( az(), undef, "az undef before init" );
throws_ok { App::CatalystStarter::Bloated::Initializr::_require_az() }
qr/^\Qaz object not initialized/, "az check dies as expected before init";
isa_ok(
App::CatalystStarter::Bloated::Initializr::_set_az_from_cache(),
"Archive::Zip"
t/initializr/process_zip.t view on Meta::CPAN
## search one
*search_one = *App::CatalystStarter::Bloated::Initializr::_safely_search_one_member;
throws_ok { search_one(qr/./) }
qr/^\QFound 0 or more than one zip member match for/,
"safe search dies on > 1 matches";
throws_ok { search_one(qr/THIS SHOULD NOT BE IN ANY OF THE ZIP MEMBERS/) }
qr/^\QFound 0 or more than one zip member match for/,
"a non matching qr also dies";
lives_ok { search_one(qr/THIS SHOULD NOT BE IN ANY OF THE ZIP MEMBERS/, 1) }
"a non matching qr lives when allowed to";
view all matches for this distribution
view release on metacpan or search on metacpan
t/002_test.t view on Meta::CPAN
{
local $Plan = {'' => 1} ;
throws_ok
{
}
qr//, 'failed' ;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Changelog2x.pm view on Meta::CPAN
# understands them.
%params = map { XML::LibXSLT::xpath_to_string($_ => $params->{$_}) }
(keys %$params);
# Do the steps of parsing XML documents, creating stylesheet engine and
# applying the transform. Each throws a die on error, so each has to be
# eval'd to allow for a cleaner error report:
eval {
$source = ref($xmlin) ?
$parser->parse_fh($xmlin) : $parser->parse_string($xmlin);
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Chart/Database.pm view on Meta::CPAN
# An eval isn't backtrace friendly, but a __DIE__ handler would be reached
# by possible normal errors caught by a handler in $subr.
#
# rollback() can get errors too, like database gone away. They end up
# thrown in preference to the original error.
#
sub call_with_transaction {
my ($dbh, $subr) = @_;
my $hold = App::Chart::chart_dirbroadcast()->hold;
view all matches for this distribution
view release on metacpan or search on metacpan
//
// MAKE.bat
g++ my.c -o my.exe
# Try Catch in Cpp
# No throw means no catch
//
#include <iostream>
using namespace std;
int main(int,char**){
int n = 10;
int m = 0;
try {
// if( m == 0 ) throw "Division by zero condition!";
int val = n / m;
cout << "Divided: " << val << endl;
}
catch (...){
cout << "Caught error" << endl;
cout << "DONE" << endl;
return 0;
}
# Nested Try Catch in Cpp
# No throw means no catch
//
#include <iostream>
using namespace std;
int main(int,char**){
int n = 10;
int m = 0;
int val;
try {
try {
if( m == 0 ) throw "Division by zero condition!";
val = n / m;
cout << "Divided: " << val << endl;
}
catch (runtime_error& e){ cout << "Caught inner error1" << endl; }
catch (out_of_range& e) { cout << "Caught inner error2" << endl; }
# Use this to allow using script tags
$(id).append(details_rc);
# Stack trace in javascript (js).
try {
// Code throwing an exception
throw new Error();
} catch(e) {
console.log(e.stack);
}
# Javascript log function wrapper.
#
$ExitOverride = 0;
# Perl signal handling (eval,die,__DIE__)
# Capture STDOUT and STDERR.
# Catch die and throw to STDOUT.
perl -MApp::Pod -E '{ local *STDOUT; open STDOUT, ">", \$out or die $!; local *STDERR; open STDERR, ">>", \$err or die $!; print "print-out"; print STDERR "print-err"; local $SIG{__DIE__} = sub{ my $m = shift; chomp $m; print STDERR "<$m>" }; eval{di...
#
# Use $@ to capture eval error.
# Better than SIG{__DIE__} since sub calls may except an die
# to stop something, like Pod::Simple, which is used by Pod::LOL).
prior to any other actions it performs,
require will check if ${^HOOK}{require__before}
contains a coderef, and if it does it will be
called with the filename form of the item being
loaded. The hook may modify $_[0] to load a
different filename, or it may throw a fatal
exception to cause the require to fail, which
will be treated as though the required code
itself had thrown an exception.
perl -E '
use warnings;
BEGIN{
${^HOOK}{require__before} = sub {
say "here: @_";
# Call a function (Vim)
# () are required.
:call Abc()
# Return a value from a function (Vim)
# :call will throw away the return value
# Use your function as an expresion instead.
:echo Abc()
# Create function inline (Vim)
# Not really friendly view.
view all matches for this distribution
view release on metacpan or search on metacpan
themes/bs2/static/js/jquery-1.7.1.min.js view on Meta::CPAN
/*! jQuery v1.7.1 jquery.com | jquery.org/license */
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("ifram...
f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){ret...
{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this...
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
sub set_debug_level {
my ( $self, $level ) = @_;
if ( !defined $level ) {
croak(
App::ClusterSSH::Exception->throw(
error => _translate('Debug level not provided')
)
);
}
if ( $level > 9 ) {
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
sub config {
my ($self) = @_;
if ( !$app_configuration ) {
croak(
App::ClusterSSH::Exception->throw(
_translate('config has not yet been set')
)
);
}
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
sub set_config {
my ( $self, $config ) = @_;
if ($app_configuration) {
croak(
App::ClusterSSH::Exception->throw(
_translate('config has already been set')
)
);
}
if ( !$config ) {
croak(
App::ClusterSSH::Exception->throw(
_translate('passed config is empty')
)
);
}
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
sub load_file {
my ( $self, %args ) = @_;
if ( !$args{filename} ) {
croak(
App::ClusterSSH::Exception->throw(
error => '"filename" arg not passed'
)
);
}
if ( !$args{type} ) {
croak(
App::ClusterSSH::Exception->throw(
error => '"type" arg not passed'
)
);
}
$self->debug( 2, 'Loading in config file: ', $args{filename} );
if ( !-e $args{filename} ) {
croak(
App::ClusterSSH::Exception::LoadFile->throw(
error => $self->loc(
'Unable to read file [_1]: [_2]' . $/, $args{filename},
$!
),
),
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
my $regexp
= $args{type} eq 'config' ? qr/\s*(\S+)\s*=\s*(.*)/
: $args{type} eq 'cluster' ? qr/\s*(\S+)\s+(.*)/
: croak(
App::ClusterSSH::Exception::LoadFile->throw(
error => 'Unknown arg type: ',
$args{type}
)
);
open( my $fh, '<', $args{filename} )
or croak(
App::ClusterSSH::Exception::LoadFile->throw(
error => $self->loc(
"Unable to read file [_1]: [_2]",
$args{filename}, $!
)
),
lib/App/ClusterSSH/Base.pm view on Meta::CPAN
}
}
close($fh)
or croak(
App::ClusterSSH::Exception::LoadFile->throw(
error => "Could not close $args{filename} after reading: $!"
),
);
return %results;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Cmd/Plugin/Prompt.pm view on Meta::CPAN
#pod B<no_valid_default:> do not test the 'default' parameter
#pod against the 'valid' coderef
#pod
#pod =item *
#pod
#pod B<invalid_default_error:> error message to throw when the
#pod 'default' parameter is not valid (does not pass the 'valid'
#pod coderef)
#pod
#pod =back
#pod
lib/App/Cmd/Plugin/Prompt.pm view on Meta::CPAN
B<no_valid_default:> do not test the 'default' parameter
against the 'valid' coderef
=item *
B<invalid_default_error:> error message to throw when the
'default' parameter is not valid (does not pass the 'valid'
coderef)
=back
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Cmd/Command.pm view on Meta::CPAN
#pod =method validate_args
#pod
#pod $command_plugin->validate_args(\%opt, \@args);
#pod
#pod This method is passed a hashref of command line options (as processed by
#pod Getopt::Long::Descriptive) and an arrayref of leftover arguments. It may throw
#pod an exception (preferably by calling C<usage_error>, below) if they are invalid,
#pod or it may do nothing to allow processing to continue.
#pod
#pod =cut
lib/App/Cmd/Command.pm view on Meta::CPAN
=head2 validate_args
$command_plugin->validate_args(\%opt, \@args);
This method is passed a hashref of command line options (as processed by
Getopt::Long::Descriptive) and an arrayref of leftover arguments. It may throw
an exception (preferably by calling C<usage_error>, below) if they are invalid,
or it may do nothing to allow processing to continue.
=head2 usage_error
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/CmdDispatch/Exception.pm view on Meta::CPAN
These exception classes simplify exceptional conditions that need a bit more
context to report that the simple fact of the exception. These are used in the
parts of the run code where we want to catch the exception and perform some
recovery.
Other places in the code where we just want to leave the program, I've thrown
simple strings instead.
=head1 INTERFACE
=head2 new( @args )
view all matches for this distribution
view release on metacpan or search on metacpan
t/command.t view on Meta::CPAN
is $subcommand->identity, 'foo baz', 'Identity of a subcommand is correct';
is $command->default_command, undef, 'default_command is undefined as expected';
like exception { $command->default_command('bad'); },
qr/bad couldn't be found in this command's list of commands./,
'Exception is thrown when an unknown name is used with default_command';
is $command->default_command($subcommand->name), $subcommand,
'default_command returns the expected Command object';
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
t/02_attribute.t view on Meta::CPAN
use Test::NoWarnings;
use App::Config::Chronicle::Attribute;
use Data::Hash::DotNotation;
throws_ok {
App::Config::Chronicle::Attribute->new(
name => 'test',
parent_path => 'apperturescience'
);
}
qr/Attribute \(data_set\) is required/;
throws_ok {
App::Config::Chronicle::Attribute->new(
name => 'test_attribute',
parent_path => 'test.parent',
data_set => {version => 1},
definition => {
t/02_attribute.t view on Meta::CPAN
},
)->build;
}
qr/ArrayRef/;
throws_ok {
App::Config::Chronicle::Attribute->new(
name => 'json_string',
parent_path => 'validation.tests',
data_set => {version => 1},
definition => {
t/02_attribute.t view on Meta::CPAN
isa => 'ArrayRef',
default => ['1', '2', '3'],
},
)->build;
throws_ok { $attribute->value('a'); } qr/ArrayRef/;
};
view all matches for this distribution
view release on metacpan or search on metacpan
for debugging and the generation of object-message traces to validate
or document the flow of messages through the system.
Detailed Conditions:
* use(001) class does not exist: throw a App::Exception
* use(002) class never used before: should succeed
* use(003) class used before: should succeed
* use(004) can use class after: should succeed
=cut
# do nothing
}
elsif ($class =~ /^([A-Za-z0-9_:]+)$/) {
eval "use $1;";
if ($@) {
App::Exception->throw(
error => "class $class failed to load: $@\n",
);
}
}
else {
App::Exception->throw(
error => "Tried to load class [$class] with illegal characters\n",
);
}
}
&App::sub_exit() if ($App::trace);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Cronjob.pm view on Meta::CPAN
alarm(0) if $opt->timeout;
1;
};
unless ($ok) {
# XXX: does not throw proper exception
$logger->log_fatal([ 'run3 failed to run command: %s', $@ ]);
}
my $status = Process::Status->new;
view all matches for this distribution
view release on metacpan or search on metacpan
0.10 2017-02-17
- new input type -i 'taparchive' backed by TAP::DOM::Archive
0.09 2015-09-30
- generalize the use of YAML with an option --yaml-module
- and throw away again format 'yaml10' which I just invented an
hour ago in version 0.08
- by default it still does not use 'YAML::Syck' though
0.08 2015-09-30
- no longer use YAML::Syck to handle input/output format 'yaml'
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
scripts/dex view on Meta::CPAN
corresponding filehandle (C<STDIN>, C<STDOUT> and C<STDERR>, resp.) will be
redirected. Because the redirects come last, this allows C<STDOUT> and
C<STDERR> to default to the parent's by just not specifying them -- a common
use case.
C<run3> throws an exception if the wrapped C<system> call returned -1 or
anything went wrong with C<run3>'s processing of filehandles. Otherwise it
returns true. It leaves C<$?> intact for inspection of exit and wait status.
Note that a true return value from C<run3> doesn't mean that the command had a
successful exit code. Hence you should always check C<$?>.
scripts/dex view on Meta::CPAN
appended to the previous contents of the string) or an ARRAY reference (the
output is C<push>ed onto the previous contents of the array).
=item C<return_if_system_error>
If this is true C<run3> does B<not> throw an exception if C<system> returns -1
(cf. L<perlfunc/system> for possible failure scenarios.), but returns true
instead. In this case C<$?> has the value -1 and C<$!> contains the errno of
the failing C<system> call.
=back
scripts/dex view on Meta::CPAN
better: returns TRUE on success, FALSE on failure
=item *
better: throws an error if problems occur in the parent process (or the
pre-exec child)
=item *
better: allows a very perlish interface to Perl data structures and subroutines
scripts/dex view on Meta::CPAN
=item Parse Tree
I would like to generate a complete parse tree, that allows you to manipulate
the data structure and also dump it, including all whitespaces and comments.
The spec says that this is throwaway content, but I read that many people
wish to be able to keep the comments.
=back
=head2 YAML::PP::Dumper, YAML::PP::Emitter
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Diskd.pm view on Meta::CPAN
# The kernel should eventually receive a SIGCHLD after this
}
# For our purposes, we don't care whether the child exited by closing
# its output or throwing a SIGCHLD. Wrap the deletion of references to
# the child in if(defined()) to avoid warnings.
sub child_cleanup {
#print "DiskWatcher: child_cleanup args: ". (join ", ", @_). "\n";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/DocKnot/Command.pm view on Meta::CPAN
# the arguments that can be passed to this subcommand.
#
# required
# A reference to an array of required option names (the part before any |
# in the option specification for that option). If any of these options
# are not set, an error will be thrown.
our %COMMANDS = (
dist => {
method => 'make_distribution',
module => 'App::DocKnot::Dist',
options => ['distdir|d=s', 'metadata|m=s', 'pgp-key|p=s'],
view all matches for this distribution
view release on metacpan or search on metacpan
prompted from user if not given in site config
- Parser.pm: add GET COO[KIES]
- Build.PL: update dependencies
0.008 2014-08-10 22:51 CEST
- fix bug "bin/dochazka-cli throws 'Odd number of arguments' error at startup"
0.009 2014-08-10 22:56 CEST
- Parser.pm: add GET SES[SION]
0.010 2014-08-11 16:15 CEST
the time
0.151 2015-04-07 17:08 CEST
- Guide.pm: start writing proper CLI documentation
- CLI.pm: move verbiage to Guide and link to it
- Parser.pm: fix RT#102671 (Trailing '0' was throwing the parser)
https://rt.cpan.org/Ticket/Display.html?id=102671
- cleanup
0.152 2015-04-07 18:39 CEST
- TokenMap.pm: add PASSWORD token and distinguish it from PASSERBY
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Dochazka/Common/Model.pm view on Meta::CPAN
map { $self->{$_} = $ARGS{$_}; } @attr;
# run the populate function, if any
$self->populate() if $self->can( 'populate' );
# return an appropriate throw-away value
return;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Dochazka/REST.pm view on Meta::CPAN
=head2 run_sql
Takes a L<DBIx::Connector> object and an array of SQL statements. Runs them
one by one until an exception is thrown or the last statement completes
successfully. Returns a status object which will be either OK or ERR.
If NOT_OK, the error text will be in C<< $status->text >>.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
0.167 2017-11-27 13:21 CET
- js: caches: check more carefully if activityCache populated; refactor masqEmployee
- js: allow inactives to view intervals
- js: hide inaccessible functionality from passerbies
- js: implement vetting of privlevels when adding/modifying status records
- js: viewer: use throw for assert-like conditions
- js: int-lib: use multi-date viewer even when no intervals in range
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/DrivePlayer/SheetDB.pm view on Meta::CPAN
# Reconcile the local DB with the sheet per these rules:
# - Both sides have a value for a field, different: DB wins.
# - One side blank/missing: fill from the other (blank = missing).
# - drive_id only in DB: add to sheet.
# - drive_id only on sheet: ask drive_exists; if exists, add to DB; else
# delete from sheet. If drive_exists throws, keep the row as-is
# (never destroy data on an API error).
# - Scan-folder list: union, never auto-delete (config is user-owned).
# Returns a summary hashref.
sub sync_with_db {
my ($self, $db, %opts) = @_;
lib/App/DrivePlayer/SheetDB.pm view on Meta::CPAN
=item *
C<drive_id> on the sheet but not in the DB: C<drive_exists-E<gt>($id)>
is called. A truthy result adds the track to the DB; a falsy result
deletes the row from the sheet. If the callback throws (API failure),
the row is preserved on both sides --sync never destroys data on error.
=item *
Scan-folder list: union only; folders are never auto-deleted because
view all matches for this distribution