You are here

public function BlogapiCommunicator::returnXmlError in Blog API 8

Handles the returning of errors.

Parameters

$error_code: The error code.

int $arg: Optional arg for t().

Return value

object The xmlrpc error object.

10 calls to BlogapiCommunicator::returnXmlError()
BlogapiCommunicator::deletePost in src/BlogapiCommunicator.php
Callback for deleting a post.
BlogapiCommunicator::editPost in src/BlogapiCommunicator.php
Callback for editing a node.
BlogapiCommunicator::getCategoryList in src/BlogapiCommunicator.php
Returns a list of available categories on a content type.
BlogapiCommunicator::getNodeCategories in src/BlogapiCommunicator.php
Returns taxonomy terms saved in the defined taxonomy field on a node.
BlogapiCommunicator::getPost in src/BlogapiCommunicator.php
Returns a loaded node object.

... See full list

File

src/BlogapiCommunicator.php, line 952

Class

BlogapiCommunicator
Class BlogapiCommunicator.

Namespace

Drupal\blogapi

Code

public function returnXmlError($error_code, $arg = 0) {
  module_load_include('inc', 'xmlrpc', 'xmlrpc');
  switch ($error_code) {
    case self::BLOGAPI_XML_ERROR_AUTH:
      return xmlrpc_error(401, t('Access denied.'));
    case self::BLOGAPI_XML_ERROR_NODE_NOT_FOUND:
      return xmlrpc_error(402, t('Node @nid not found.', [
        '@nid' => $arg,
      ]));
    case self::BLOGAPI_XML_ERROR_NODE_ACCESS:
      return xmlrpc_error(403, t('Access to node @nid denied.', [
        '@nid' => $arg,
      ]));
    case self::BLOGAPI_XML_ERROR_NODE_UPDATE:
      return xmlrpc_error(404, t('You do not have permission to update node @nid.', [
        '@nid' => $arg,
      ]));
    case self::BLOGAPI_XML_ERROR_CT:
      return xmlrpc_error(405, t('Can not access content type with BlogAPI.'));
    case self::BLOGAPI_XML_ERROR_NODE_CREATE:
      return xmlrpc_error(406, t('You do not have permission to create this type of node.'));
    case self::BLOGAPI_XML_ERROR_NODE_DELETE:
      return xmlrpc_error(407, t('You do not have permission to delete node @nid.', $arg));
    case self::BLOGAPI_XML_ERROR_IMG_SIZE:
      return xmlrpc_error(408, t('Error uploading file because it exceeded the maximum filesize of @maxsize.', array(
        '@maxsize' => format_size($arg),
      )));
    case self::BLOGAPI_XML_ERROR_IMG_SAVE:
      return xmlrpc_error(409, t('Error storing file.'));
    default:
      return xmlrpc_error(400, t('Fatal error.'));
  }
}