Template for error notification.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-08-29 09:44:05 +00:00
parent 236f74c1d8
commit 37049ba6f4
4 changed files with 98 additions and 90 deletions

View File

@ -51,7 +51,12 @@ class App
return touch($path);
}
),
'templates' => Expect::structure(['notify' => Expect::string()])
'templates' => Expect::structure(
[
'notify' => Expect::string(),
'error' => Expect::string()
]
)
]);
$parser = new Yaml();

View File

@ -70,9 +70,9 @@ class CommandBackup extends Command
/** @var array{title: string, source: string, destination: string} $conf */
foreach ($sio->progressIterate($backupElements) as $conf) {
$title = $conf['title'];
$template = array();
$template['config'] = $conf;
try {
$template = array();
$template['config'] = $conf;
$template['start'] = new DateTime();
$template['source_size'] = $rclone->getSize($conf['source']);
$template['rclone_version'] = $rclone->getVersion();
@ -87,10 +87,10 @@ class CommandBackup extends Command
$message = $render->render('notify', $template);
} catch (\Exception $e) {
$message = $e->getMessage();
$template['exception'] = $e->getMessage();
$message = $render->render('error', $template);
$sio->error($message);
}
$notification->send($title, $message);
}