warnings) $this->warnings = array(); array_push($this->warnings, $warning); } function handle_exception($e) { $this->error = $e->getMessage(); $this->respond(); } function respond() { header('Content-Type: application/json'); $response = array("status" => $this->error ? "error" : "success"); if ($this->error) $response["error"] = $this->error; if ($this->warnings) $response["warnings"] = $this->warnings; die(json_encode($response)); } }