Snuze Exception classes
The classes described here are in the
Snuze exception overview
When Snuze encounters a problem, it throws an exception. The exceptions raised
by Snuze are descendants of
SnuzeException. This is a
special type of exception that copies its error message to the log file
(assuming one is enabled), even if you catch it. This allows you to swallow minor
exceptions while your script keeps running, then scan the log file occasionally to
see if anything funky is going on.
Devising an error handling strategy is left up to you.
Some exceptions are less severe than others; you might just want to catch them
and move on. Others indicate a dire and unrecoverable problem that should
result in your script terminating. Snuze itself never calls
exit; it can only
interrupt execution if you don't handle its exceptions.
\snuze\Exception\SnuzeException class is the ancestor of all other
exception types listed below. It does a few things above and beyond a regular
Its code property e.g.
$ex->getCode()is forced to an integer type, despite the best efforts of certain PHP extensions;
When thrown by a
SnuzeObjectsubtype, the short class name and Snuze internal identifier of the
SnuzeObjectwill be prepended to the error message to assist with troubleshooting;
The error message will be logged to the Snuze log file, if one is enabled.
\snuze\Exception\ArgumentException is thrown when a Snuze method encounters
an argument it either wasn't expecting or can't handle. For example, calling
fetchSubreddit('t-e-s-t') will throw an
ArgumentException, because the
specified subreddit name is invalid.
\snuze\Exception\AuthenticationException is thrown when Snuze can't
authenticate with the API server, or receives a "401 Unauthorized" response
from the API server after making a request. This may indicate a problem with
the Reddit credentials Snuze is configured to use.
\snuze\Exception\ForbiddenException is thrown when Snuze receives a
"403 Forbidden" response from the API server. The most frequent cause is
attempting to fetch something that the authenticated user doesn't have permission
to access, like a private or quarantined subreddit.
\snuze\Exception\NotFoundException is thrown when Snuze receives a
"404 Not Found" response from the API server. The most frequent cause is
attempting to fetch something that's no longer available, like a deleted link
or a banned subreddit.
\snuze\Exception\PersistenceException is thrown when Snuze encounters a
problem related to a storage provider. In the MySQL storage provider, this
often indicates a database column width issue; if the message mentions data
truncation, please file a bug report.
\snuze\Exception\RateLimitException is thrown when your script exceeds the
Reddit API rate limit and you have the
\snuze\Exception\RuntimeException is a catch-all exception. It's thrown when
Snuze has a problem that isn't suited to a more specific exception type.
\snuze\Exception\ServerErrorException is thrown when Snuze receives a
500-series HTTP response code from the API server. This indicates a server
problem on Reddit's end. It's suggested that you catch these and
awhile to give Reddit time to recover.