public static function sendException(\Exception $ex)
	{
		$class = get_class($ex);
		switch ($class) {
			case 'Smalldb\\StateMachine\\TransitionAccessException':
				$http_code = '403';
				break;
			case 'Smalldb\\StateMachine\\InstanceDoesNotExistException':
				$http_code = '404';
				break;
			default:
				$http_code = '500';
				break;
		}

		header("HTTP/1.0 $http_code Exception: $class");
		header('Content-Type: application/json; encoding=utf-8');
		static::writeException($ex);
	}