We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

disable display error, using try catch

HI!,

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



58.4k

Hi

You try this

try {

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


7.6k

i have something like that:

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

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

                        $transaction->commit();

                        $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');
                    }