We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

disable display error, using try catch


quite simple anserw: i have phalcon project and i use transaction manager to catching errors while inserting to DB. and i have try{}catch{$this->flash->error()} but when goes something wrong (e.g. too long string) i have printed SQL error.

How to disable showing errors and show page with flash message?

Best regards



You try this

try {

    } catch (Exception $e) {
        $this->flash->error('This is test messages');


i have something like that:

                    try {
                        $manager = $this->transaction;
                        $transaction = $manager->get();

                        if (!$rank->save()) {
                            $transaction->rollback('Update user error');


                        $this->flashSession->success('Dodano rangę poprawnie');
                        return $this->response->redirect('admin/calendar/rank');
                    } catch (Phalcon\Mvc\Model\Transaction\Failed $e) {
                        $this->logger->alert("Updating / activating user account problems: \n" . $e->getMessage());
                        $this->flash->error('Wystąpił błąd. Spróbuj ponownie lub skontaktuj się z obsługą aplikacji');