Улучшил обработку ошибок

This commit is contained in:
Фёдор Подлеснов 2016-07-28 11:19:47 +03:00
parent b84e13f769
commit 3ebc007b8d
3 changed files with 11 additions and 5 deletions

View file

@ -332,6 +332,11 @@ class Controller
$request->session()->clean('page');
return $result;
}
function redirect($action) {
header('location: ' . $this->fUrl($action));
exit();
}
}
class Controller_Action extends Controller {}

View file

@ -193,10 +193,10 @@ class Mail
function send()
{
$result = mail($this->to, $this->getSubject(), $this->getMessage(), $this->getHeader());
// $result = false;
if(! $result) {
require_once "core/path.php";
file_put_contents(Path::resolveFile("data/email/send.eml"), $this->eml());
throw new Exception('Невозможно отправить почту');
// require_once "core/path.php";
// file_put_contents(Path::resolveFile("data/email/send.eml"), $this->eml());
}
return $result;
}

View file

@ -41,7 +41,8 @@ class Validator
// Формат правила 'rule1|rule2,param1=value1|rule3,param1=value1,param2=value2'
foreach ($input as $value) {
// Список правил
if (! isset($value['validate'])) continue;
if (!isset($value['validate']) || $value['validate'] == '') continue;
$rules = explode("|", $value['validate']);
foreach ($rules as $rule) {
// Список параметров правила
@ -61,7 +62,7 @@ class Validator
}
$this->addRule($rule);
} else {
throw new Exception('Unknown validation rule ' . $name);
throw new Exception('Unknown validation rule "' . $rule . "'");
}
}
}