[dev] Horde::logMessage usage

Vilius Šumskas vilius at lnk.lt
Sat Jul 9 13:29:55 UTC 2011


Hi,

  My question probably a stupid one, but my head hurts when things
  comes to exception handling.

  What  is  a  current  policy  regarding  Horde::logMessage()  usage?
  Particularly   I'm   interested   in  do I have to use logMessage($e,
  'ERR') after Horde_Db_Exception  is  caught? As far as I understand DB exceptions
  are logged at debug level anyway, right?

  Similarly what about Horde_Exception_NotFound or Horde_Exception_PermissionDenied?

  An example from Ulaform:

if ($fieldform->validate($vars)) {
    /* Save field if valid and the current and old field type match. */
    $fieldform->getInfo($vars, $info);
    try {
        $save_field = $injector->getInstance('Ulaform_Factory_Driver')->create()->saveField($info);
        $notification->push(_("Field saved."), 'horde.success');
        $url = Horde::url('fields.php', true);
        $url = Horde_Util::addParameter($url, array('form_id' => $info['form_id']),
                                  null, false);
        header('Location: ' . $url);
        exit;
    } catch (Horde_Exception $e) {
        Horde::logMessage($e->getMessage(), 'ERR');
        $notification->push(sprintf(_("Error saving field. %s."), $e->getMessage()), 'horde.error');
    }
}


saveField() throws Horde_Db_Exception or Horde_Exception_NotFound. Do
I really need logMessage at that point?

--
Best regards,
 Vilius



More information about the dev mailing list