Add exception for ambiguous abbreviated hash
[gitphp.git] / include / exception / AmbiguousHashException.class.php
blob:a/include/exception/AmbiguousHashException.class.php -> blob:b/include/exception/AmbiguousHashException.class.php
--- a/include/exception/AmbiguousHashException.class.php
+++ b/include/exception/AmbiguousHashException.class.php
@@ -1,1 +1,34 @@
+<?php
+/**
+ * Custom exception when an ambiguous abbreviated hash is specified
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2012 Christopher Han
+ * @package GitPHP
+ * @subpackage Exception
+ */
+class GitPHP_AmbiguousHashException extends GitPHP_MessageException
+{
+	/**
+	 * Hash
+	 *
+	 * @var string
+	 */
+	public $Hash;
 
+	/** 
+	 * Constructor
+	 *
+	 * @param string $hash hash
+	 * @param string $message message
+	 * @param integer $code exception code
+	 */
+	public function __construct($hash, $message = '', $code = 0)
+	{
+		$this->Hash = $hash;
+		if (empty($message))
+			$message = 'Ambiguous abbreviated hash %1$s';
+		parent::__construct($message, true, 200, $code);
+	}
+}
+

comments