Use messageexception for known end user messages
Use messageexception for known end user messages

--- a/include/git/GitObject.class.php
+++ b/include/git/GitObject.class.php
@@ -107,7 +107,7 @@
 	protected function SetHash($hash)
 	{
 		if (!preg_match('/^[0-9A-Fa-f]{40}$/', $hash)) {
-			throw new Exception(sprintf(__('Invalid hash %1$s'), $hash));
+			throw new GitPHP_MessageException(sprintf(__('Invalid hash %1$s'), $hash));
 		}
 		$this->hash = $hash;
 	}

--- a/include/git/Pack.class.php
+++ b/include/git/Pack.class.php
@@ -72,7 +72,7 @@
 	public function __construct($project, $hash)
 	{
 		if (!(preg_match('/[0-9A-Fa-f]{40}/', $hash))) {
-			throw new Exception(sprintf(__('Invalid hash %1$s'), $hash));
+			throw new GitPHP_MessageException(sprintf(__('Invalid hash %1$s'), $hash));
 		}
 		$this->hash = $hash;
 		$this->project = $project;

--- a/include/git/Project.class.php
+++ b/include/git/Project.class.php
@@ -250,21 +250,21 @@
 		$fullPath = realpath($path);
 
 		if (!is_dir($fullPath)) {
-			throw new Exception(sprintf(__('%1$s is not a directory'), $project));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is not a directory'), $project));
 		}
 
 		if (!is_file($fullPath . '/HEAD')) {
-			throw new Exception(sprintf(__('%1$s is not a git repository'), $project));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is not a git repository'), $project));
 		}
 
 		if (preg_match('/(^|\/)\.{0,2}(\/|$)/', $project)) {
-			throw new Exception(sprintf(__('%1$s is attempting directory traversal'), $project));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is attempting directory traversal'), $project));
 		}
 
 		$pathPiece = substr($fullPath, 0, strlen($realProjectRoot));
 
 		if ((!is_link($path)) && (strcmp($pathPiece, $realProjectRoot) !== 0)) {
-			throw new Exception(sprintf(__('%1$s is outside of the projectroot'), $project));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is outside of the projectroot'), $project));
 		}
 
 		$this->project = $project;

--- a/include/git/projectlist/ProjectListBase.class.php
+++ b/include/git/projectlist/ProjectListBase.class.php
@@ -106,7 +106,7 @@
 			throw new GitPHP_MessageException(__('A projectroot must be set in the config'), true, 500);
 		}
 		if (!is_dir($this->projectRoot)) {
-			throw new Exception(sprintf(__('%1$s is not a directory'), $this->projectRoot));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is not a directory'), $this->projectRoot));
 		}
 
 		$this->memoryCache = new GitPHP_MemoryCache(GitPHP_Config::GetInstance()->GetValue('objectmemory', 0));

--- a/include/git/projectlist/ProjectListFile.class.php
+++ b/include/git/projectlist/ProjectListFile.class.php
@@ -34,7 +34,7 @@
 	public function __construct($projectRoot, $projectFile)
 	{
 		if (!(is_string($projectFile) && is_file($projectFile))) {
-			throw new Exception(sprintf(__('%1$s is not a file'), $projectFile));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is not a file'), $projectFile));
 		}
 
 		$this->projectConfig = $projectFile;
@@ -120,7 +120,7 @@
 		$fileString = file_get_contents($this->projectConfig);
 		
 		if ($fileString === false) {
-			throw new Exception(sprintf(__('Failed to open project list file %1$s'), $this->projectConfig));
+			throw new GitPHP_MessageException(sprintf(__('Failed to open project list file %1$s'), $this->projectConfig));
 		}
 
 		$this->fileContents = array();

--- a/include/git/projectlist/ProjectListScmManager.class.php
+++ b/include/git/projectlist/ProjectListScmManager.class.php
@@ -33,7 +33,7 @@
 	public function __construct($projectRoot, $projectFile)
 	{
 		if (!(is_string($projectFile) && is_file($projectFile))) {
-			throw new Exception(sprintf(__('%1$s is not a file'), $projectFile));
+			throw new GitPHP_MessageException(sprintf(__('%1$s is not a file'), $projectFile));
 		}
 
 		$this->projectConfig = $projectFile;

comments