<?php

namespace App\Utils\Webservice\Rest;

abstract class ResponseAbstract
{

	/**
	 * Response status: ok, error.
	 * @var string
	 */
	public $status = 'ok';

	/**
	 * Usually it contains the error message.
	 * @var string
	 */
	public $message;

	/**
	 * The error code.
	 * @var string
	 */
	public $errorCode;


	public function setErrorMessage($errorMessage, $errorCode=null)
	{
		$this->status = 'error';
		$this->message = $errorMessage;
		$this->errorCode = $errorCode;
	}

	public function applyRuntimeException(\Exception $e)
	{
		$this->setErrorMessage($e->getMessage(), $e->getCode()?:null);
	}


}