Throw an error when an invalid path is specified in the url
[gitphp.git] / include / exception / FileNotFoundException.class.php
blob:a/include/exception/FileNotFoundException.class.php -> blob:b/include/exception/FileNotFoundException.class.php
--- a/include/exception/FileNotFoundException.class.php
+++ b/include/exception/FileNotFoundException.class.php
@@ -1,1 +1,34 @@
+<?php
+/**
+ * Custom exception when a specified file is not found
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2012 Christopher Han
+ * @package GitPHP
+ * @subpackage Exception
+ */
+class GitPHP_FileNotFoundException extends GitPHP_MessageException
+{
+	/**
+	 * File
+	 *
+	 * @var string
+	 */
+	public $File;
 
+	/**
+	 * Constructor
+	 *
+	 * @param string $file file
+	 * @param string $message message
+	 * @param int $code exception code
+	 */
+	public function __construct($file, $message = '', $code = 0)
+	{
+		$this->File = $file;
+		if (empty($message))
+			$message = sprintf('File %1$s not found', $file);
+		parent::__construct($message, true, 404, $code);
+	}
+}
+

comments