forked from GNUsocial/gnu-social
Add plain text error format to clientError()
This commit is contained in:
parent
83566f014c
commit
4247be5116
@ -1247,20 +1247,26 @@ class ApiAction extends Action
|
|||||||
header('HTTP/1.1 ' . $code . ' ' . $status_string);
|
header('HTTP/1.1 ' . $code . ' ' . $status_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == 'xml') {
|
switch($format) {
|
||||||
|
case 'xml':
|
||||||
$this->initDocument('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
$this->element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
$this->elementEnd('hash');
|
$this->elementEnd('hash');
|
||||||
$this->endDocument('xml');
|
$this->endDocument('xml');
|
||||||
} elseif ($format == 'json'){
|
break;
|
||||||
|
case 'json':
|
||||||
$this->initDocument('json');
|
$this->initDocument('json');
|
||||||
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
||||||
print(json_encode($error_array));
|
print(json_encode($error_array));
|
||||||
$this->endDocument('json');
|
$this->endDocument('json');
|
||||||
} else {
|
break;
|
||||||
|
case 'text':
|
||||||
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
|
print $msg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
// If user didn't request a useful format, throw a regular client error
|
// If user didn't request a useful format, throw a regular client error
|
||||||
throw new ClientException($msg, $code);
|
throw new ClientException($msg, $code);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user