From 50185ab8f6cd72e5f7a9cec4cc230a19a72c3896 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 17 Nov 2017 22:53:54 -0500 Subject: [PATCH] Change code and type of consantUnknown exception --- lib/AbstractException.php | 2 +- lib/Database.php | 2 +- locale/en.php | 3 ++- tests/lib/Database/SeriesArticle.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/AbstractException.php b/lib/AbstractException.php index 5c7ec40..0806a13 100644 --- a/lib/AbstractException.php +++ b/lib/AbstractException.php @@ -10,6 +10,7 @@ abstract class AbstractException extends \Exception { const CODES = [ "Exception.uncoded" => -1, "Exception.unknown" => 10000, + "Exception.constantUnknown" => 10001, "ExceptionType.strictFailure" => 10011, "ExceptionType.typeUnknown" => 10012, "Lang/Exception.defaultFileMissing" => 10101, @@ -41,7 +42,6 @@ abstract class AbstractException extends \Exception { "Db/Exception.savepointInvalid" => 10226, "Db/Exception.savepointStale" => 10227, "Db/Exception.resultReused" => 10228, - "Db/Exception.constantUnknown" => 10229, "Db/ExceptionInput.missing" => 10231, "Db/ExceptionInput.whitespace" => 10232, "Db/ExceptionInput.tooLong" => 10233, diff --git a/lib/Database.php b/lib/Database.php index d67f386..00cd3ca 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -1019,7 +1019,7 @@ class Database { // id, subscription, feed, modified_date, marked_date, unread, starred, edition break; default: - throw new Db\Exception("constantUnknown", $fields); + throw new Exception("constantUnknown", $fields); } $q = $this->articleQuery($user, $context, $columns); $q->setJoin("left join arsse_enclosures on arsse_enclosures.article is arsse_articles.id"); diff --git a/locale/en.php b/locale/en.php index f2f2148..e284847 100644 --- a/locale/en.php +++ b/locale/en.php @@ -85,6 +85,8 @@ return [ 'Exception.JKingWeb/Arsse/Exception.uncoded' => 'The specified exception symbol {0} has no code specified in AbstractException.php', // this should not usually be encountered 'Exception.JKingWeb/Arsse/Exception.unknown' => 'An unknown error has occurred', + // indicates programming error + 'Exception.JKingWeb/Arsse/Exception.constantUnknown' => 'Supplied constant value ({0}) is unknown or invalid in the context in which it was used', 'Exception.JKingWeb/Arsse/ExceptionType.strictFailure' => 'Supplied value could not be normalized to {0, select, 1 {null} 2 {boolean} @@ -142,7 +144,6 @@ return [ 'Exception.JKingWeb/Arsse/Db/Exception.savepointInvalid' => 'Tried to {action} invalid savepoint {index}', 'Exception.JKingWeb/Arsse/Db/Exception.savepointStale' => 'Tried to {action} stale savepoint {index}', 'Exception.JKingWeb/Arsse/Db/Exception.resultReused' => 'Result set already iterated', - 'Exception.JKingWeb/Arsse/Db/Exception.constantUnknown' => 'Supplied constant value ({0}) is unknown or invalid in the context in which it was used', 'Exception.JKingWeb/Arsse/Db/ExceptionInput.missing' => 'Required field "{field}" missing while performing action "{action}"', 'Exception.JKingWeb/Arsse/Db/ExceptionInput.whitespace' => 'Field "{field}" of action "{action}" may not contain only whitespace', 'Exception.JKingWeb/Arsse/Db/ExceptionInput.tooLong' => 'Field "{field}" of action "{action}" has a maximum length of {max}', diff --git a/tests/lib/Database/SeriesArticle.php b/tests/lib/Database/SeriesArticle.php index afab611..9fcbbbf 100644 --- a/tests/lib/Database/SeriesArticle.php +++ b/tests/lib/Database/SeriesArticle.php @@ -474,7 +474,7 @@ trait SeriesArticle { $this->assertEquals($columns, $test, "Fields do not match expectation for verbosity $constant"); } // check that an unknown fieldset produces an exception - $this->assertException("constantUnknown", "Db", "Exception"); + $this->assertException("constantUnknown"); Arsse::$db->articleList($this->user, (new Context)->article(101), \PHP_INT_MAX); }