Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/perl/native/Core.pm view on Meta::CPAN
If you set the $SVN::Error::handler to undef then each call will return an
svn_error_t object as its first return in the case of an error, followed by the
normal return values. If there is no error then a svn_error_t will not be
returned and only the normal return values will be returned. When using this
mode you should be careful only to call functions in array context. For
example: my ($ci) = $ctx-E<gt>mkdir('http://svn/foo'); In this case $ci will
be an svn_error_t object if an error occurs and a svn_client_commit_info object
otherwise. If you leave the parenthesis off around $ci (scalar context) it
will be the commit_info object, which in the case of an error will be undef.
If you plan on using explicit exception handling, understanding the exception
handling system the C API uses is helpful. You can find information on it in
the HACKING file and the API documentation. Looking at the implementation of
SVN::Error::croak_on_error and SVN::Error::expanded_message may be helpful as
well.
=over 4
=item $svn_error_t-E<gt>apr_err()
APR error value, possibly SVN_ custom error.
=item $svn_error_t-E<gt>message()
Details from producer of error.
=item $svn_error_t-E<gt>child()
svn_error_t object of the error that's wrapped.
=item $svn_error_t-E<gt>pool()
The pool holding this error and any child errors it wraps.
=item $svn_error_t-E<gt>file()
Source file where the error originated.
=item $svn_error_t-E<gt>line()
Source line where the error originated.
=item SVN::Error::strerror($apr_status_t)
Returns the english description of the status code.
=item $svn_error_t-E<gt>strerror()
Returns the english description of the apr_err status code set on the
$svn_error_t. This is short for:
SVN::Error::strerror($svn_error_t-E<gt>apr_err());
=item SVN::Error::create($apr_err, $child, $message);
Returns a new svn_error_t object with the error status specified in $apr_err,
the child as $child, and error message of $message.
=item SVN::Error::quick_wrap($child, $new_msg); or $child-E<gt>quick_wrap($new_msg);
A quick n' easy way to create a wrappered exception with your own message
before throwing it up the stack.
$child is the svn_error_t object you want to wrap and $new_msg is the new error
string you want to set.
=item SVN::Error::compose($chain, $new_error); or $chain-E<gt>compose($new_error);
Add new_err to the end of $chain's chain of errors.
The $new_err chain will be copied into $chain's pool and destroyed, so $new_err
itself becomes invalid after this function.
=item SVN::Error::clear($svn_error_t); or $svn_error_t-E<gt>clear();
Free the memory used by $svn_error_t, as well as all ancestors and descendants
of $svn_error_t.
You must call this on every svn_error_t object you get or you will leak memory.
=cut
# Permit users to determine if they want automatic croaking or not.
our $handler = \&croak_on_error;
# Import functions that don't follow the normal naming scheme.
foreach my $function (qw(handle_error handle_warning strerror)) {
no strict 'refs';
my $real_function = \&{"SVN::_Core::svn_$function"};
*{"SVN::Error::$function"} = sub {
return $real_function->(@_);
}
}
=item SVN::Error::expanded_message($svn_error_t) or $svn_error_t-E<gt>expanded_message()
Returns the error message by tracing through the svn_error_t object and its
children and concatenating the error messages. This is how the internal
exception handlers get their error messages.
=cut
sub expanded_message {
my $svn_error = shift;
unless (is_error($svn_error)) {
return undef;
}
my $error_message = $svn_error->strerror();
while ($svn_error) {
my $msg = $svn_error->message();
$error_message .= ": $msg" if $msg;
$svn_error = $svn_error->child();
}
return $error_message;
}
=item SVN::Error::is_error($value)
Returns true if value is of type svn_error. Returns false if value is
anything else or undefined. This is useful for seeing if a call has returned
( run in 0.636 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )