Changes

stoney cloud: Notification Architecture

1,270 bytes added, 08:49, 20 June 2014
/* How to use the Notification.pm module */
$notification->notify();
</source>
 
As you can see, it is pretty easy to use the notification module if you followed the set up as described in the [[#Requirements | requirements]] section.
== Error handling ==
After each method of the notification object, you might want to check whether or not there was an error by calling the <code>error</code> method (for example after connecting to the backend):
<source lang="perl">
$notification->connectToBackend( $ldap_server,
$ldap_port,
$ldap_bind_dn,
$ldap_bind_pw,
);
 
# Check if the backup connection could be established
if ( $notification->error() )
{
# Log what went wrong
if ( $debug )
{
print "Debug: Cannot connect to LDAP server $ldap_server: "
.$notification->error()."\n";
}
syslog('err',"Cannot connect to LDAP server $ldap_server: "
.$notification->error() );
}
</source>
<code>$notification->error()</code> returns the error message if there was an error. If no error occurred, <code>$notification->error()</code> returns a false value. There is also a method <code>$notification->errorCode()</code> which returns the error code (numeric value).
= Source Code =
486
edits