/** * @param string $action * @param \Sky\Page $page */ public static function runRequest($action, \Sky\Page $page) { $request = new self($page); try { $request->run($action)->finish(); } catch (\ValidationException $e) { $request->response = array('status' => 'Error', 'type' => 'ValidationException', 'errors' => array_map(function ($o) { return $o->message; }, $e->getErrors())); $request->finish(); } catch (\Exception $e) { $request->response = array('status' => 'Error', 'type' => 'Exception', 'errors' => array($e->getMessage())); $request->finish(); } }