posts($page, $limit, $sort)); } catch (Exception $err) { switch ($err->getMessage()) { case "NotFound": throw ApiError::notFound("user"); default: // Due to how the failed field is handled, it's ApiError is inside the models update throw $err; } } } }