Ferreteria/v0.6/clade/Sys/Events/ItWent/CommOp/MsgsOp
Jump to navigation
Jump to search
| ||||||||||||||
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 -- //
}