diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -15,25 +15,25 @@ 'AASTTree' => 'parser/aast/api/AASTTree.php', 'AbstractDirectedGraph' => 'utils/AbstractDirectedGraph.php', 'AbstractDirectedGraphTestCase' => 'utils/__tests__/AbstractDirectedGraphTestCase.php', + 'AphrontCharacterSetQueryException' => 'aphront/storage/exception/AphrontCharacterSetQueryException.php', + 'AphrontConnectionLostQueryException' => 'aphront/storage/exception/AphrontConnectionLostQueryException.php', + 'AphrontConnectionQueryException' => 'aphront/storage/exception/AphrontConnectionQueryException.php', + 'AphrontCountQueryException' => 'aphront/storage/exception/AphrontCountQueryException.php', 'AphrontDatabaseConnection' => 'aphront/storage/connection/AphrontDatabaseConnection.php', 'AphrontDatabaseTransactionState' => 'aphront/storage/connection/AphrontDatabaseTransactionState.php', + 'AphrontDeadlockQueryException' => 'aphront/storage/exception/AphrontDeadlockQueryException.php', + 'AphrontDuplicateKeyQueryException' => 'aphront/storage/exception/AphrontDuplicateKeyQueryException.php', 'AphrontIsolatedDatabaseConnection' => 'aphront/storage/connection/AphrontIsolatedDatabaseConnection.php', 'AphrontMySQLDatabaseConnection' => 'aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php', 'AphrontMySQLDatabaseConnectionBase' => 'aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php', 'AphrontMySQLiDatabaseConnection' => 'aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php', + 'AphrontNotSupportedQueryException' => 'aphront/storage/exception/AphrontNotSupportedQueryException.php', + 'AphrontObjectMissingQueryException' => 'aphront/storage/exception/AphrontObjectMissingQueryException.php', + 'AphrontParameterQueryException' => 'aphront/storage/exception/AphrontParameterQueryException.php', 'AphrontQueryAccessDeniedException' => 'aphront/storage/exception/AphrontQueryAccessDeniedException.php', - 'AphrontQueryCharacterSetException' => 'aphront/storage/exception/AphrontQueryCharacterSetException.php', - 'AphrontQueryConnectionException' => 'aphront/storage/exception/AphrontQueryConnectionException.php', - 'AphrontQueryConnectionLostException' => 'aphront/storage/exception/AphrontQueryConnectionLostException.php', - 'AphrontQueryCountException' => 'aphront/storage/exception/AphrontQueryCountException.php', - 'AphrontQueryDeadlockException' => 'aphront/storage/exception/AphrontQueryDeadlockException.php', - 'AphrontQueryDuplicateKeyException' => 'aphront/storage/exception/AphrontQueryDuplicateKeyException.php', 'AphrontQueryException' => 'aphront/storage/exception/AphrontQueryException.php', - 'AphrontQueryNotSupportedException' => 'aphront/storage/exception/AphrontQueryNotSupportedException.php', - 'AphrontQueryObjectMissingException' => 'aphront/storage/exception/AphrontQueryObjectMissingException.php', - 'AphrontQueryParameterException' => 'aphront/storage/exception/AphrontQueryParameterException.php', - 'AphrontQueryRecoverableException' => 'aphront/storage/exception/AphrontQueryRecoverableException.php', - 'AphrontQuerySchemaException' => 'aphront/storage/exception/AphrontQuerySchemaException.php', + 'AphrontRecoverableQueryException' => 'aphront/storage/exception/AphrontRecoverableQueryException.php', + 'AphrontSchemaQueryException' => 'aphront/storage/exception/AphrontSchemaQueryException.php', 'AphrontScopedUnguardedWriteCapability' => 'aphront/writeguard/AphrontScopedUnguardedWriteCapability.php', 'AphrontWriteGuard' => 'aphront/writeguard/AphrontWriteGuard.php', 'AphrontWriteGuardExitEventListener' => 'aphront/writeguard/event/AphrontWriteGuardExitEventListener.php', @@ -470,24 +470,24 @@ 'Countable', ), 'AbstractDirectedGraphTestCase' => 'PhutilTestCase', + 'AphrontCharacterSetQueryException' => 'AphrontQueryException', + 'AphrontConnectionLostQueryException' => 'AphrontRecoverableQueryException', + 'AphrontConnectionQueryException' => 'AphrontQueryException', + 'AphrontCountQueryException' => 'AphrontQueryException', 'AphrontDatabaseConnection' => 'PhutilQsprintfInterface', + 'AphrontDeadlockQueryException' => 'AphrontRecoverableQueryException', + 'AphrontDuplicateKeyQueryException' => 'AphrontQueryException', 'AphrontIsolatedDatabaseConnection' => 'AphrontDatabaseConnection', 'AphrontMySQLDatabaseConnection' => 'AphrontMySQLDatabaseConnectionBase', 'AphrontMySQLDatabaseConnectionBase' => 'AphrontDatabaseConnection', 'AphrontMySQLiDatabaseConnection' => 'AphrontMySQLDatabaseConnectionBase', - 'AphrontQueryAccessDeniedException' => 'AphrontQueryRecoverableException', - 'AphrontQueryCharacterSetException' => 'AphrontQueryException', - 'AphrontQueryConnectionException' => 'AphrontQueryException', - 'AphrontQueryConnectionLostException' => 'AphrontQueryRecoverableException', - 'AphrontQueryCountException' => 'AphrontQueryException', - 'AphrontQueryDeadlockException' => 'AphrontQueryRecoverableException', - 'AphrontQueryDuplicateKeyException' => 'AphrontQueryException', + 'AphrontNotSupportedQueryException' => 'AphrontQueryException', + 'AphrontObjectMissingQueryException' => 'AphrontQueryException', + 'AphrontParameterQueryException' => 'AphrontQueryException', + 'AphrontQueryAccessDeniedException' => 'AphrontRecoverableQueryException', 'AphrontQueryException' => 'Exception', - 'AphrontQueryNotSupportedException' => 'AphrontQueryException', - 'AphrontQueryObjectMissingException' => 'AphrontQueryException', - 'AphrontQueryParameterException' => 'AphrontQueryException', - 'AphrontQueryRecoverableException' => 'AphrontQueryException', - 'AphrontQuerySchemaException' => 'AphrontQueryException', + 'AphrontRecoverableQueryException' => 'AphrontQueryException', + 'AphrontSchemaQueryException' => 'AphrontQueryException', 'AphrontWriteGuardExitEventListener' => 'PhutilEventListener', 'BaseHTTPFuture' => 'Future', 'CommandException' => 'Exception', diff --git a/src/aphront/storage/connection/AphrontIsolatedDatabaseConnection.php b/src/aphront/storage/connection/AphrontIsolatedDatabaseConnection.php --- a/src/aphront/storage/connection/AphrontIsolatedDatabaseConnection.php +++ b/src/aphront/storage/connection/AphrontIsolatedDatabaseConnection.php @@ -81,7 +81,7 @@ $preg_keywords = implode('|', $preg_keywords); if (!preg_match('/^[\s<>K]*('.$preg_keywords.')\s*/i', $raw_query)) { - throw new AphrontQueryNotSupportedException( + throw new AphrontNotSupportedQueryException( "Database isolation currently only supports some queries. You are ". "trying to issue a query which does not begin with an allowed ". "keyword (".implode(', ', $keywords)."): '".$raw_query."'"); diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php --- a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php +++ b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php @@ -60,7 +60,7 @@ if (!$conn) { $errno = mysql_errno(); $error = mysql_error(); - throw new AphrontQueryConnectionException( + throw new AphrontConnectionQueryException( "Attempt to connect to {$user}@{$host} failed with error ". "#{$errno}: {$error}.", $errno); } diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php --- a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php +++ b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php @@ -179,7 +179,7 @@ } $this->throwQueryException($this->connection); - } catch (AphrontQueryConnectionLostException $ex) { + } catch (AphrontConnectionLostQueryException $ex) { if ($this->isInsideTransaction()) { // Zero out the transaction state to prevent a second exception // ("program exited with open transaction") from being thrown, since @@ -280,20 +280,20 @@ switch ($errno) { case 2013: // Connection Dropped - throw new AphrontQueryConnectionLostException($exmsg); + throw new AphrontConnectionLostQueryException($exmsg); case 2006: // Gone Away $more = "This error may occur if your MySQL 'wait_timeout' ". "or 'max_allowed_packet' configuration values are set too low."; - throw new AphrontQueryConnectionLostException("{$exmsg}\n\n{$more}"); + throw new AphrontConnectionLostQueryException("{$exmsg}\n\n{$more}"); case 1213: // Deadlock case 1205: // Lock wait timeout exceeded - throw new AphrontQueryDeadlockException($exmsg); + throw new AphrontDeadlockQueryException($exmsg); case 1062: // Duplicate Key // NOTE: In some versions of MySQL we get a key name back here, but // older versions just give us a key index ("key 2") so it's not // portable to parse the key out of the error and attach it to the // exception. - throw new AphrontQueryDuplicateKeyException($exmsg); + throw new AphrontDuplicateKeyQueryException($exmsg); case 1044: // Access denied to database case 1045: // Access denied (auth) case 1142: // Access denied to table @@ -302,7 +302,7 @@ case 1146: // No such table case 1049: // No such database case 1054: // Unknown column "..." in field list - throw new AphrontQuerySchemaException($exmsg); + throw new AphrontSchemaQueryException($exmsg); default: // TODO: 1064 is syntax error, and quite terrible in production. throw new AphrontQueryException($exmsg); @@ -328,7 +328,7 @@ return; } - throw new AphrontQueryCharacterSetException( + throw new AphrontCharacterSetQueryException( pht( 'Attempting to construct a query containing characters outside of '. 'the Unicode Basic Multilingual Plane. MySQL will silently truncate '. diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php --- a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php +++ b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php @@ -62,7 +62,7 @@ $errno = $conn->connect_errno; if ($errno) { $error = $conn->connect_error; - throw new AphrontQueryConnectionException( + throw new AphrontConnectionQueryException( "Attempt to connect to {$user}@{$host} failed with error ". "#{$errno}: {$error}.", $errno); } diff --git a/src/aphront/storage/exception/AphrontCharacterSetQueryException.php b/src/aphront/storage/exception/AphrontCharacterSetQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontCharacterSetQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontCharacterSetQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontConnectionLostQueryException.php b/src/aphront/storage/exception/AphrontConnectionLostQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontConnectionLostQueryException.php @@ -0,0 +1,4 @@ +<?php + +final class AphrontConnectionLostQueryException + extends AphrontRecoverableQueryException {} diff --git a/src/aphront/storage/exception/AphrontConnectionQueryException.php b/src/aphront/storage/exception/AphrontConnectionQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontConnectionQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontConnectionQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontCountQueryException.php b/src/aphront/storage/exception/AphrontCountQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontCountQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontCountQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontDeadlockQueryException.php b/src/aphront/storage/exception/AphrontDeadlockQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontDeadlockQueryException.php @@ -0,0 +1,4 @@ +<?php + +final class AphrontDeadlockQueryException + extends AphrontRecoverableQueryException {} diff --git a/src/aphront/storage/exception/AphrontDuplicateKeyQueryException.php b/src/aphront/storage/exception/AphrontDuplicateKeyQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontDuplicateKeyQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontDuplicateKeyQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontNotSupportedQueryException.php b/src/aphront/storage/exception/AphrontNotSupportedQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontNotSupportedQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontNotSupportedQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontObjectMissingQueryException.php b/src/aphront/storage/exception/AphrontObjectMissingQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontObjectMissingQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontObjectMissingQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryParameterException.php b/src/aphront/storage/exception/AphrontParameterQueryException.php rename from src/aphront/storage/exception/AphrontQueryParameterException.php rename to src/aphront/storage/exception/AphrontParameterQueryException.php --- a/src/aphront/storage/exception/AphrontQueryParameterException.php +++ b/src/aphront/storage/exception/AphrontParameterQueryException.php @@ -1,6 +1,6 @@ <?php -final class AphrontQueryParameterException extends AphrontQueryException { +final class AphrontParameterQueryException extends AphrontQueryException { private $query; diff --git a/src/aphront/storage/exception/AphrontQueryAccessDeniedException.php b/src/aphront/storage/exception/AphrontQueryAccessDeniedException.php --- a/src/aphront/storage/exception/AphrontQueryAccessDeniedException.php +++ b/src/aphront/storage/exception/AphrontQueryAccessDeniedException.php @@ -1,4 +1,4 @@ <?php final class AphrontQueryAccessDeniedException - extends AphrontQueryRecoverableException {} + extends AphrontRecoverableQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryCharacterSetException.php b/src/aphront/storage/exception/AphrontQueryCharacterSetException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryCharacterSetException.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -final class AphrontQueryCharacterSetException extends AphrontQueryException { - -} diff --git a/src/aphront/storage/exception/AphrontQueryConnectionException.php b/src/aphront/storage/exception/AphrontQueryConnectionException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryConnectionException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQueryConnectionException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryConnectionLostException.php b/src/aphront/storage/exception/AphrontQueryConnectionLostException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryConnectionLostException.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -final class AphrontQueryConnectionLostException - extends AphrontQueryRecoverableException {} diff --git a/src/aphront/storage/exception/AphrontQueryCountException.php b/src/aphront/storage/exception/AphrontQueryCountException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryCountException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQueryCountException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryDeadlockException.php b/src/aphront/storage/exception/AphrontQueryDeadlockException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryDeadlockException.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -final class AphrontQueryDeadlockException - extends AphrontQueryRecoverableException {} diff --git a/src/aphront/storage/exception/AphrontQueryDuplicateKeyException.php b/src/aphront/storage/exception/AphrontQueryDuplicateKeyException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryDuplicateKeyException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQueryDuplicateKeyException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryNotSupportedException.php b/src/aphront/storage/exception/AphrontQueryNotSupportedException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryNotSupportedException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQueryNotSupportedException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryObjectMissingException.php b/src/aphront/storage/exception/AphrontQueryObjectMissingException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryObjectMissingException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQueryObjectMissingException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQueryRecoverableException.php b/src/aphront/storage/exception/AphrontQueryRecoverableException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQueryRecoverableException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -abstract class AphrontQueryRecoverableException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontQuerySchemaException.php b/src/aphront/storage/exception/AphrontQuerySchemaException.php deleted file mode 100644 --- a/src/aphront/storage/exception/AphrontQuerySchemaException.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -final class AphrontQuerySchemaException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontRecoverableQueryException.php b/src/aphront/storage/exception/AphrontRecoverableQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontRecoverableQueryException.php @@ -0,0 +1,3 @@ +<?php + +abstract class AphrontRecoverableQueryException extends AphrontQueryException {} diff --git a/src/aphront/storage/exception/AphrontSchemaQueryException.php b/src/aphront/storage/exception/AphrontSchemaQueryException.php new file mode 100644 --- /dev/null +++ b/src/aphront/storage/exception/AphrontSchemaQueryException.php @@ -0,0 +1,3 @@ +<?php + +final class AphrontSchemaQueryException extends AphrontQueryException {} diff --git a/src/xsprintf/qsprintf.php b/src/xsprintf/qsprintf.php --- a/src/xsprintf/qsprintf.php +++ b/src/xsprintf/qsprintf.php @@ -244,12 +244,12 @@ case 'LC': case 'LB': if (!is_array($value)) { - throw new AphrontQueryParameterException( + throw new AphrontParameterQueryException( $query, "Expected array argument for %{$type} conversion."); } if (empty($value)) { - throw new AphrontQueryParameterException( + throw new AphrontParameterQueryException( $query, "Array for %{$type} conversion is empty."); } @@ -271,7 +271,7 @@ case 'T': case 'C': if (!is_string($value)) { - throw new AphrontQueryParameterException( + throw new AphrontParameterQueryException( $query, "Expected a string for %{$type} conversion."); } @@ -281,7 +281,7 @@ case 'd': case 'f': if (!is_null($value) && !is_numeric($value)) { - throw new AphrontQueryParameterException( + throw new AphrontParameterQueryException( $query, "Expected a numeric scalar or null for %{$type} conversion."); } @@ -296,7 +296,7 @@ case '<': case 'K': if (!is_null($value) && !is_scalar($value)) { - throw new AphrontQueryParameterException( + throw new AphrontParameterQueryException( $query, "Expected a scalar or null for %{$type} conversion."); } diff --git a/src/xsprintf/queryfx.php b/src/xsprintf/queryfx.php --- a/src/xsprintf/queryfx.php +++ b/src/xsprintf/queryfx.php @@ -21,7 +21,7 @@ $argv = func_get_args(); $ret = call_user_func_array('queryfx_all', $argv); if (count($ret) > 1) { - throw new AphrontQueryCountException('Query returned more than one row.'); + throw new AphrontCountQueryException('Query returned more than one row.'); } else if (count($ret)) { return reset($ret); }