Template for error notification.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user