public function save() { try { return parent::save(); } catch (\MongoException $e) { return false; } }
public function save() { $result = parent::save(); if (!$result) { throw new \Exception(); } return true; }
/** * The save function stores the assigned fields into * the database. Overloaded to... * - handle exceptions * - convert objects to references before saving */ public function save() { //convert objects into refs $this->deepObjToRef(); //TODO: Put that in a library class. //TODO: use layout set_exception_handler(function (\Exception $e) { if (ob_get_level() > 0) { ob_end_clean(); } echo '<html><head><title>Exception - ', get_class($e), ': ', $e->getMessage(), '</title></head><body>'; echo '<div class="error-main"> ', get_class($e), ': ', $e->getMessage(), ' <br/><span class="error-file">', $e->getFile(), ' (', $e->getLine(), ')</span> </div>'; echo '<div class="error-backtrace"><table cellspacing="0">'; //echo "<pre>"; var_dump($e->getTrace()); echo "</pre>"; foreach ($e->getTrace() as $n => $trace) { echo "<hr>"; if ($has_line = isset($trace["file"]) && isset($trace["line"])) { echo "<p>" . $trace["file"] . " line " . $trace["line"] . "</p>"; } if ($has_class = isset($trace["class"]) && isset($trace["function"])) { echo "<p>" . $trace["class"] . "::" . $trace["function"] . "</p>"; } if (!$has_line && !$has_class) { echo "<pre>"; var_dump($trace); echo "</pre>"; } } echo '</table></div>'; echo '</body></html>'; }); $success = parent::save(); restore_exception_handler(); //convert refs back into objects $this->deepRefToObj(); return $success; }
public function save() { return parent::save(); }