163 lines
3.7 KiB
HTML
163 lines
3.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Net::DBus::Error</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Net::DBus::Error</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-12-26<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Net::DBus::Error - Error details for remote method invocation
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
package Music::Player::UnknownFormat;
|
|
|
|
use base qw(Net::DBus::Error);
|
|
|
|
# Define an error type for unknown track encoding type
|
|
# for a music player service
|
|
sub new {
|
|
my $proto = shift;
|
|
my $class = ref($proto) || $proto;
|
|
my $self = $class->SUPER::new(name => "org.example.music.UnknownFormat",
|
|
message => "Unknown track encoding format");
|
|
}
|
|
|
|
|
|
package Music::Player::Engine;
|
|
|
|
...snip...
|
|
|
|
# Play either mp3 or ogg music tracks, otherwise
|
|
# thrown an error
|
|
sub play {
|
|
my $self = shift;
|
|
my $url = shift;
|
|
|
|
if ($url =~ /\.(mp3|ogg)$/) {
|
|
...play the track
|
|
} else {
|
|
die Music::Player::UnknownFormat->new();
|
|
}
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This objects provides for strongly typed error handling. Normally
|
|
a service would simply call
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
die "some message text"
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
When returning the error condition to the calling DBus client, the
|
|
message is associated with a generic error code or ``org.freedesktop.DBus.Failed''.
|
|
While this suffices for many applications, occasionally it is desirable
|
|
to be able to catch and handle specific error conditions. For such
|
|
scenarios the service should create subclasses of the <TT>"Net::DBus::Error"</TT>
|
|
object providing in a custom error name. This error name is then sent back
|
|
to the client instead of the genreic ``org.freedesktop.DBus.Failed'' code.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">my $error = Net::DBus::Error->new(name => $error_name, message => $description);<DD>
|
|
|
|
|
|
|
|
|
|
Creates a new error object whose name is given by the <TT>"name"</TT>
|
|
parameter, and long descriptive text is provided by the
|
|
<TT>"message"</TT> parameter. The <TT>"name"</TT> parameter has certain
|
|
formatting rules which must be adhered to. It must only contain
|
|
the letters 'a'-'Z', '0'-'9', '-', '_' and '.'. There must be
|
|
at least two components separated by a '.', For example a valid
|
|
name is 'org.example.Music.UnknownFormat'.
|
|
<DT id="2">$error->name<DD>
|
|
|
|
|
|
|
|
|
|
Returns the DBus error name associated with the object.
|
|
<DT id="3">$error->message<DD>
|
|
|
|
|
|
|
|
|
|
Returns the descriptive text/message associated with the
|
|
error condition.
|
|
<DT id="4">$error->stringify<DD>
|
|
|
|
|
|
|
|
|
|
Formats the error as a string in a manner suitable for
|
|
printing out / logging / displaying to the user, etc.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Daniel P. Berrange
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (C) 2005-2011 Daniel P. Berrange
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
Net::DBus, Net::DBus::Object
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="8"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DT id="9"><A HREF="#lbAF">AUTHOR</A><DD>
|
|
<DT id="10"><A HREF="#lbAG">COPYRIGHT</A><DD>
|
|
<DT id="11"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:49 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|