Exception and smarty-Collection of common programming errors

I have block try – catch and i want assign error to the template to $error. I tried:

catch (Exception $e) {
   $smarty->assign("error", 'Error! Details: '.$e->getMessage());
}

Also tried:

catch (Exception $e) {
   $error = $e->getMessage());
}
$smarty->assign("error", $error);

But when there is no error, smarty requires this variable and all crashes. Is there any way to deal with it without using if? Or may be i am doing wrong from the begining?