Ferreteria/v0.6/clade/Sys/Events/ItWent/CommOp/MsgsOp: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
|fam= | |fam= | ||
{{!}} align=right {{!}} {{l/ver/clade|Sys\Events\ItWent|CommOp}} | {{!}} align=right {{!}} {{l/ver/clade|Sys\Events\ItWent|CommOp}} | ||
{{!}} → {{l/ver/clade|Sys\Events\ItWent\CommOp|MsgsOp}} | {{!}} align=center {{!}} → {{l/ver/clade|Sys\Events\ItWent\CommOp|MsgsOp}} → | ||
{{!}} | {{!}} align=left {{!}} (Maria) {{l/ver/clade|Sys\Data\aux\Maria|ItWent}} | ||
|alia= | |alia= | ||
{{!}}- | {{!}}- | ||
{{!}} '''Base'''* [c,i] {{!}}{{!}} {{l/ver/clade/full|Sys\Events\ItWent|CommOp}} | {{!}} '''Base'''* [c,i] {{!}}{{!}} {{l/ver/clade/full|p=ferreteria|Sys\Events\ItWent|CommOp}} | ||
}} | |||
==Code== | |||
''as of 2025-10-31'' | |||
{{fmt/php/block|1= | |||
interface iMsgsOp extends BaseIface { | |||
// ACTION | |||
function HandleResults() : void; | |||
} | |||
abstract class caMsgsOp extends BaseClass implements iMsgsOp { | |||
// ++ CONFIG ++ // | |||
abstract protected function ErrorsAdminClass() : string; | |||
// -- CONFIG -- // | |||
// ++ ACTION ++ // | |||
// PURPOSE: do any result-checking that is common to most data ops, and display appropriate messages | |||
public function HandleResults() : void { | |||
$oAct = $this; | |||
$ok = $oAct->GetOkay(); | |||
if (!$ok) { | |||
$oScrn = self::Screen(); | |||
// Successful connection will sometimes give warnings (mainly the one about putting a password on the command-line), | |||
// which the Shell object will interpret as failure, so we need to see if this is a warning or an error: | |||
if ($oAct->AnyMessages()) { | |||
$arMsg = $oAct->AllMessages(); | |||
$nMsg = count($arMsg); | |||
foreach ($arMsg as $oMsg) { | |||
$sMsg = $oMsg->Text(); | |||
$this->CheckMessage($sMsg); | |||
} | |||
} | |||
} | |||
} | |||
protected function CheckMessage(string $sMsg) { | |||
$oScrn = self::Screen(); | |||
$oMsg = ($this->ErrorsAdminClass())::FromMessage($sMsg); | |||
if (is_object($oMsg)) { | |||
// For now, all the recognized errors aren't serious problems -- so we'll call this a warning message. | |||
#$isWarning = TRUE; | |||
$sShow = $oMsg->Full(); | |||
} else { | |||
#$isWarning = FALSE; | |||
$sShow = $oScrn->ErrorIt('Error').': '.$sMsg; | |||
} | |||
/* | |||
if ($isWarning) { | |||
$this->SetOkay(TRUE); // not an actual error | |||
$sPre = $oScrn->YellowIt('Warning'); | |||
} else { | |||
$sPre = $oScrn->ErrorIt('Error'); | |||
} | |||
echo CRLF.$sPre.': '.$sShow.CRLF; | |||
*/ | |||
echo CRLF.$sShow.CRLF; // not sure why "bytes saved" isn't doing a CRLF | |||
} | |||
// -- ACTION -- // | |||
} | |||
}} | }} | ||
Latest revision as of 23:39, 31 October 2025
| ||||||||||||||
Code
as of 2025-10-31
interface iMsgsOp extends BaseIface {
// ACTION
function HandleResults() : void;
}
abstract class caMsgsOp extends BaseClass implements iMsgsOp {
// ++ CONFIG ++ //
abstract protected function ErrorsAdminClass() : string;
// -- CONFIG -- //
// ++ ACTION ++ //
// PURPOSE: do any result-checking that is common to most data ops, and display appropriate messages
public function HandleResults() : void {
$oAct = $this;
$ok = $oAct->GetOkay();
if (!$ok) {
$oScrn = self::Screen();
// Successful connection will sometimes give warnings (mainly the one about putting a password on the command-line),
// which the Shell object will interpret as failure, so we need to see if this is a warning or an error:
if ($oAct->AnyMessages()) {
$arMsg = $oAct->AllMessages();
$nMsg = count($arMsg);
foreach ($arMsg as $oMsg) {
$sMsg = $oMsg->Text();
$this->CheckMessage($sMsg);
}
}
}
}
protected function CheckMessage(string $sMsg) {
$oScrn = self::Screen();
$oMsg = ($this->ErrorsAdminClass())::FromMessage($sMsg);
if (is_object($oMsg)) {
// For now, all the recognized errors aren't serious problems -- so we'll call this a warning message.
#$isWarning = TRUE;
$sShow = $oMsg->Full();
} else {
#$isWarning = FALSE;
$sShow = $oScrn->ErrorIt('Error').': '.$sMsg;
}
/*
if ($isWarning) {
$this->SetOkay(TRUE); // not an actual error
$sPre = $oScrn->YellowIt('Warning');
} else {
$sPre = $oScrn->ErrorIt('Error');
}
echo CRLF.$sPre.': '.$sShow.CRLF;
*/
echo CRLF.$sShow.CRLF; // not sure why "bytes saved" isn't doing a CRLF
}
// -- ACTION -- //
}