Skip to content

Commit db504da

Browse files
committed
error handling
1 parent 68cd9b5 commit db504da

2 files changed

Lines changed: 57 additions & 21 deletions

File tree

lam/lib/modules/posixAccount.inc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -942,19 +942,24 @@ class posixAccount extends baseModule implements passwordService {
942942
// try to delete directory on all servers
943943
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
944944
$remote = new \LAM\REMOTE\Remote();
945-
$remote->connect($lamdaemonServers[$i]);
946-
$result = $remote->execute(
947-
implode(
948-
self::$SPLIT_DELIMITER,
949-
array(
950-
$this->attributes['uid'][0],
951-
"home",
952-
"rem",
953-
$this->attributes[$homeDirAttr][0],
954-
$this->attributes['uidNumber'][0]
955-
)
956-
));
957-
$remote->disconnect();
945+
try {
946+
$remote->connect($lamdaemonServers[$i]);
947+
$result = $remote->execute(
948+
implode(
949+
self::$SPLIT_DELIMITER,
950+
array(
951+
$this->attributes['uid'][0],
952+
"home",
953+
"rem",
954+
$this->attributes[$homeDirAttr][0],
955+
$this->attributes['uidNumber'][0]
956+
)
957+
));
958+
$remote->disconnect();
959+
}
960+
catch (LAMException $e) {
961+
$return[] = array('ERROR', $e->getTitle(), $e->getMessage());
962+
}
958963
// lamdaemon results
959964
if (!empty($result)) {
960965
$singleresult = explode(",", $result);

lam/lib/modules/quota.inc

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,15 @@ class quota extends baseModule {
336336
* @return array Array which contains status messages. Each entry is an array containing the status message parameters.
337337
*/
338338
function preDeleteActions() {
339-
$this->initQuotas();
340-
if (!isset($this->quota) || !is_array($this->quota)) return array();
339+
try {
340+
$this->initQuotas();
341+
}
342+
catch (LAMException $e) {
343+
return array(array('ERROR', $e->getTitle(), $e->getMessage()));
344+
}
345+
if (!isset($this->quota) || !is_array($this->quota)) {
346+
return array();
347+
}
341348
// determine if this is a user or group account
342349
if ($this->get_scope()=='user') {
343350
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
@@ -427,8 +434,16 @@ class quota extends baseModule {
427434
*/
428435
function display_html_attributes() {
429436
$return = new htmlTable();
430-
$this->initQuotas();
431-
if (!is_array($this->quota)) return $return;
437+
try {
438+
$this->initQuotas();
439+
}
440+
catch (LAMException $e) {
441+
$return->addElement(new htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()));
442+
return $return;
443+
}
444+
if (!is_array($this->quota)) {
445+
return $return;
446+
}
432447
// get list of lamdaemon servers
433448
$serverDescriptions = array();
434449
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
@@ -671,8 +686,16 @@ class quota extends baseModule {
671686
* @see baseModule::get_pdfEntries()
672687
*/
673688
function get_pdfEntries($pdfKeys, $typeId) {
674-
$this->initQuotas();
675-
if (!isset($this->quota) || !is_array($this->quota)) return array();
689+
try {
690+
$this->initQuotas();
691+
}
692+
catch (LAMException $e) {
693+
logNewMessage(LOG_ERR, $e->getTitle(), $e->getMessage());
694+
return array();
695+
}
696+
if (!isset($this->quota) || !is_array($this->quota)) {
697+
return array();
698+
}
676699
if (sizeof($this->quota) > 0) {
677700
$pdfTable = new PDFTable();
678701
// get list of lamdaemon servers
@@ -720,8 +743,16 @@ class quota extends baseModule {
720743
* @see baseModule::get_uploadColumns()
721744
*/
722745
function get_uploadColumns($selectedModules, &$type) {
723-
$this->initQuotas();
724-
if (!isset($this->quota) || !is_array($this->quota)) return array();
746+
try {
747+
$this->initQuotas();
748+
}
749+
catch (LAMException $e) {
750+
logNewMessage(LOG_ERR, $e->getTitle(), $e->getMessage());
751+
return array();
752+
}
753+
if (!isset($this->quota) || !is_array($this->quota)) {
754+
return array();
755+
}
725756
$return = array();
726757
if (sizeof($this->quota) > 0) {
727758
// get list of lamdaemon servers

0 commit comments

Comments
 (0)