/** See JSONMessage constructor. $ex must be-a Exception or a string describing an exception. If !$ex then a useless default message is used, reminding the caller to pass the second argument. */ public function __construct(JSONRequest $req, $ex) { if (!$req instanceof JSONRequest) { $req = new JSONRequest(); $req->setType("error"); } parent::__construct($req); if (!$ex instanceof Exception) { if (!$ex) { $ex = "No error text passed to " . __CLASS__ . "::__construct(request,error)."; } $ex = new JSONError('' . $ex, JSONMessage::ErrIDException); } $code = $ex->getCode(); if (!$code) { $code = JSONMessage::ErrIDException; } $this->setResult($code, $ex->getMessage()); }