public function format($resourceId, $output) {
        $output = parent::format($resourceId, $output);

        if (isset($output)) {
            $this->validateResponse($output);
        }

        return $output;
    }
    public function format($resourceId, $output) {
        $output = parent::format($resourceId, $output);

        $result = NULL;
        if (isset($output)) {
            $result = json_decode($output, TRUE);
            if (!isset($result)) {
                throw new IllegalStateException(t('Could not parse output of %resourceId resource call', array('%resourceId' => $resourceId)));
            }

            if (isset($result['error'])) {
                throw new IllegalStateException($result['error']);
            }
        }

        return $result;
    }
    public function format($resourceId, $output) {
        $output = parent::format($resourceId, $output);

        if (isset($output)) {
            $parsedOutput = json_decode($output, TRUE);
            if (isset($parsedOutput)) {
                if (isset($parsedOutput['RemoteException'])) {
                    $message = isset($parsedOutput['RemoteException']['message'])
                        ? $parsedOutput['RemoteException']['message']
                        : 'Error message is not provided';

                    throw new IllegalStateException(t(
                        'Resource %resourceId executed with error: %error',
                        array(
                            '%resourceId' => $resourceId,
                            '%error' => $message)));
                }
            }
        }

        return $output;
    }