[Pkg-owncloud-commits] [owncloud] 55/153: Use exceptions for in input validation.

David Prévot taffit at moszumanska.debian.org
Tue May 27 03:05:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit f1d05d204e5ce788ffcfaed04d3c4a06233eb231
Author: Andreas Fischer <bantu at owncloud.com>
Date:   Tue Apr 15 18:14:26 2014 +0200

    Use exceptions for in input validation.
---
 core/command/db/converttype.php | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index 02dc453..6fcaeac 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -97,23 +97,24 @@ class ConvertType extends Command {
 	protected function validateInput(InputInterface $input, OutputInterface $output) {
 		$type = $input->getArgument('type');
 		if ($this->connectionFactory->normalizeType($type) === 'sqlite3') {
-			$output->writeln('<error>Converting to SQLite (sqlite3) is currently not supported.</error>');
-			return 1;
+			throw new \InvalidArgumentException(
+				'Converting to SQLite (sqlite3) is currently not supported.'
+			);
 		}
 		if ($type === $this->config->getValue('dbtype', '')) {
-			$output->writeln(sprintf(
-				'<error>Can not convert from %1$s to %1$s.</error>',
+			throw new \InvalidArgumentException(sprintf(
+				'Can not convert from %1$s to %1$s.',
 				$type
 			));
-			return 1;
 		}
 		if ($type === 'oci' && $input->getOption('clear-schema')) {
 			// Doctrine unconditionally tries (at least in version 2.3)
 			// to drop sequence triggers when dropping a table, even though
 			// such triggers may not exist. This results in errors like
 			// "ORA-04080: trigger 'OC_STORAGES_AI_PK' does not exist".
-			$output->writeln('<error>The --clear-schema option is not supported when converting to Oracle (oci).</error>');
-			return 1;
+			throw new \InvalidArgumentException(
+				'The --clear-schema option is not supported when converting to Oracle (oci).'
+			);
 		}
 	}
 
@@ -148,11 +149,7 @@ class ConvertType extends Command {
 	}
 
 	protected function execute(InputInterface $input, OutputInterface $output) {
-		$inputError = $this->validateInput($input, $output);
-		if ($inputError) {
-			return $inputError;
-		}
-
+		$this->validateInput($input, $output);
 		$this->readPassword($input, $output);
 
 		$fromDB = \OC_DB::getConnection();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list