Fix: Better error management

This commit is contained in:
Laurent Destailleur 2011-10-25 02:08:42 +02:00
parent 7f5aeea9b8
commit 8418a5e7f5

View File

@ -91,7 +91,7 @@ class ActionComm extends CommonObject
/** /**
* Add an action/event into database * Add an action/event into database
* *
* @param User $user Object user making action * @param User $user Object user making action
* @param int $notrigger 1 = disable triggers, 0 = enable triggers * @param int $notrigger 1 = disable triggers, 0 = enable triggers
* @return int Id of created event, < 0 if KO * @return int Id of created event, < 0 if KO
@ -126,10 +126,15 @@ class ActionComm extends CommonObject
// Get id from code // Get id from code
$cactioncomm=new CActionComm($this->db); $cactioncomm=new CActionComm($this->db);
$result=$cactioncomm->fetch($this->type_code); $result=$cactioncomm->fetch($this->type_code);
if ($result) if ($result > 0)
{ {
$this->type_id=$cactioncomm->id; $this->type_id=$cactioncomm->id;
} }
else if ($result == 0)
{
$this->error='Failed to get record with code AC_OTH from dictionnary "type of events"';
return -1;
}
else else
{ {
$this->error=$cactioncomm->error; $this->error=$cactioncomm->error;
@ -219,7 +224,7 @@ class ActionComm extends CommonObject
/** /**
* Charge l'objet action depuis la base * Charge l'objet action depuis la base
* *
* @param int $id id de l'action a recuperer * @param int $id id de l'action a recuperer
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -307,7 +312,7 @@ class ActionComm extends CommonObject
/** /**
* Supprime l'action de la base * Supprime l'action de la base
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete() function delete()
@ -480,7 +485,7 @@ class ActionComm extends CommonObject
/** /**
* Charge les informations d'ordre info dans l'objet facture * Charge les informations d'ordre info dans l'objet facture
* *
* @param int $id Id de la facture a charger * @param int $id Id de la facture a charger
* @return void * @return void
*/ */
@ -530,7 +535,7 @@ class ActionComm extends CommonObject
/** /**
* Return label of status * Return label of status
* *
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param hidenastatus 1=Show nothing if status is "Not applicable" * @param hidenastatus 1=Show nothing if status is "Not applicable"
* @return string String with status * @return string String with status