require_once dirname(__FILE__) . '/lib/base.php';
/* Spawn the file object. */
-$fl = $VC->getFileObject($where, array('cache' => $cache));
-Chora::checkError($fl);
+try {
+ $fl = $VC->getFileObject($where, array('cache' => $cache));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$rev_ob = $VC->getRevisionObject();
/* Retrieve the desired revision from the GET variable. */
}
$ann = $VC->getAnnotateObject($fl);
-Chora::checkError($lines = $ann->doAnnotate($rev));
+try {
+ $lines = $ann->doAnnotate($rev);
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$title = sprintf(_("Source Annotation of %s (revision %s)"), Text::htmlAllSpaces($where), $rev);
$extraLink = sprintf('<a href="%s">%s</a> | <a href="%s">%s</a>',
$rev_ob = $VC->getRevisionObject();
if ($atdir) {
- Chora::checkError($dir = $VC->queryDir($where));
-
- $atticFlags = (bool)$acts['sa'];
- Chora::checkError($dir->browseDir($cache, true, $atticFlags));
- $dir->applySort($acts['sbt'], $acts['ord']);
- Chora::checkError($dirList = &$dir->queryDirList());
- Chora::checkError($fileList = $dir->queryFileList($atticFlags));
+ try {
+ $dir = $VC->queryDir($where);
+ $atticFlags = (bool)$acts['sa'];
+ $dir->browseDir($cache, true, $atticFlags);
+ $dir->applySort($acts['sbt'], $acts['ord']);
+ $dirList = &$dir->queryDirList();
+ $fileList = $dir->queryFileList($atticFlags);
+ } catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+ }
/* Decide what title to display. */
$title = ($where == '')
continue;
}
$lg = $currFile->queryLastLog();
- if (is_a($lg, 'PEAR_Error')) {
- continue;
- }
$realname = $currFile->queryName();
$mimeType = Horde_Mime_Magic::filenameToMIME($realname);
/* Showing a file. */
$onb = Util::getFormData('onb');
-$fl = $VC->getFileObject($where, array('cache' => $cache, 'branch' => $onb));
-Chora::checkError($fl);
+try {
+ $fl = $VC->getFileObject($where, array('cache' => $cache, 'branch' => $onb));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
+
$title = sprintf(_("Revisions for %s"), $where);
$extraLink = Chora::getFileViews();
$plain = Util::getFormData('p', 0);
/* Create the VC_File object and populate it. */
-$file = $VC->getFileObject($where, array('cache' => $cache));
-Chora::checkError($file);
+try {
+ $file = $VC->getFileObject($where, array('cache' => $cache));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
/* Get the revision number. */
$r = Util::getFormData('r');
}
/* Retrieve the actual checkout. */
-$checkOut = $VC->getCheckout($file, $r);
+try {
+ $checkOut = $VC->getCheckout($file, $r);
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
/* Get the MIME type of the file, or at least our best guess at it. */
$mime_type = Horde_Mime_Magic::filenameToMIME($fullname);
$mime_type = 'text/plain';
}
-/* Check error status, and either show error page, or the checkout
- * contents */
-Chora::checkError($checkOut);
-
if (!$plain) {
/* Pretty-print the checked out copy */
$pretty = Chora::pretty($mime_type, $checkOut);
require_once dirname(__FILE__) . '/lib/base.php';
/* Spawn the repository and file objects */
-$fl = $VC->getFileObject($where, array('cache' => $cache));
-Chora::checkError($fl);
+try {
+ $fl = $VC->getFileObject($where, array('cache' => $cache));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$rev_ob = $VC->getRevisionObject();
/* Initialise the form variables correctly. */
}
/* Spawn the file object. */
-$fl = $VC->getFileObject($where, array('cache' => $cache));
-Chora::checkError($fl);
+try {
+ $fl = $VC->getFileObject($where, array('cache' => $cache));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$rev_ob = $VC->getRevisionObject();
$colset = array('#ccdeff', '#ecf', '#fec', '#efc', '#cfd', '#dcdba0');
$sourceroot = $acts['rt'];
$conf['paths']['temp'] = Horde::getTempDir();
- $GLOBALS['VC'] = Horde_Vcs::factory(String::ucfirst($sourcerootopts['type']),
- array('sourceroot' => $sourcerootopts['location'],
- 'paths' => $conf['paths'],
- 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '',
- 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
- if (is_a($GLOBALS['VC'], 'PEAR_Error')) {
- Chora::fatal($GLOBALS['VC']->getMessage());
+ try {
+ $GLOBALS['VC'] = Horde_Vcs::factory(String::ucfirst($sourcerootopts['type']),
+ array('sourceroot' => $sourcerootopts['location'],
+ 'paths' => $conf['paths'],
+ 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '',
+ 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
+ } catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
}
$conf['paths']['sourceroot'] = $sourcerootopts['location'];
global $registry, $conf, $notification, $browser, $prefs;
+ if (is_a($message, 'Horde_Vcs_Exception')) {
+ $message = $message->getMessage();
+ }
+
/* Don't store the bad file in the user's preferences. */
$prefs->setValue('last_file', '');
}
/**
- * Given a return object from a Horde_Vcs:: call, make sure
- * that it's not a PEAR_Error object.
- *
- * @param mixed $e Return object from a Horde_Vcs:: call.
- */
- static public function checkError($e)
- {
- if (is_a($e, 'PEAR_Error')) {
- Chora::fatal($e->getMessage());
- }
- }
-
- /**
* Convert a commit-name into whatever the user wants.
*
* @param string $name Account name.
Chora::fatal(sprintf(_("%s: no such file or directory"), $where), '404 Not Found');
}
-$ps = $VC->getPatchsetObject($where, $cache);
-Chora::checkError($ps);
+try {
+ $ps = $VC->getPatchsetObject($where, $cache);
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$title = sprintf(_("Patchsets for %s"), $where);
$extraLink = Chora::getFileViews();
require_once dirname(__FILE__) . '/lib/base.php';
-$fl = $VC->getFileObject($where, array('cache' => $cache));
-Chora::checkError($fl);
+try {
+ $fl = $VC->getFileObject($where, array('cache' => $cache));
+} catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+}
$extraLink = Chora::getFileViews();