<?php
/**
 * Controlled scan failure.
 *
 * @package LocalGuardScanner
 */

namespace LocalGuardScanner\Application\Scan;

use RuntimeException;

/**
 * Carries only a closed failure code and stage across application boundaries.
 */
final class ScanFailure extends RuntimeException {
	/** @var string */
	private $failure_code;
	/** @var string */
	private $failure_stage;

	/**
	 * @param string $failure_code  Closed catalog code.
	 * @param string $failure_stage Scan stage.
	 */
	public function __construct( $failure_code, $failure_stage ) {
		$this->failure_code  = ScanFailureCatalog::sanitize_code( $failure_code );
		$this->failure_stage = ScanFailureCatalog::sanitize_stage( $failure_stage );
		parent::__construct( 'The scan stopped safely.' );
	}

	/** @return string */
	public function failure_code() {
		return $this->failure_code;
	}

	/** @return string */
	public function failure_stage() {
		return $this->failure_stage;
	}
}
