ServerException.php

Summary
ServerException.php
ServerExceptionClass for server-side exceptions in postActiv
ServerExceptionSubclass of PHP Exception for server errors.
__constructConstructor for the exception, which by default will log the exception even if otherwise it’s caught.
__toStringReturn a string representation of the exception.
AlreadyFulfilledExceptionClass for an exception when trying to do something that was probably already done.
UnsupportedMediaExceptionClass for a server exception caused by handling an unsupported media type, typically through an attachment/file upload.
UseFileAsThumbnailExceptionA specific variant of UnsupportedMediaException where we do not have a thumbnail generated for the given file.
UnknownUriExceptionClass for server exception caused by something specifying a URI that we cannot find or reach.
UnknownMimeExtensionExceptionClass for unknown MIME extension exception.
UnknownExtensionMimeExceptionClass for unknown extension MIME type exception.
NoticeSaveExceptionClass for a server exception caused when a notice cannot be saved.
FileNotFoundExceptionClass for a server exception caused by being unable to find something we know should be stored locally.
NoResultExceptionClass for an exception when a database lookup returns no results
NoSuchUserExceptionClass for a server exception caused by a user lookup which fails.
NoSuchGroupExceptionClass for a server exception caused by a group lookup which fails.
NoQueueHandlerExceptionClass for a server exception caused by finding no queue handler for a given transport.
NoProfileExceptionParent class for an exception when a profile is missing.
UserNoProfileExceptionClass for an exception when the user profile is missing
getUserReturns the user with a missing profile.
GroupNoProfileExceptionBasically UserNoProfileException, but for groups
getGroupReturns the group with a missing profile.
NoParentNoticeExceptionClass for a server exception caused by a notice not having a parent.
NoAvatarExceptionClass for a server exception caused by not being able to find the avatar for a given user.
NoObjectTypeExceptionClass for a server exception caused by a notice having no given type; most often this will happen because of an unrecognized activity verb.
NoRouteMapExceptionClass for a server exception caused by not finding a route map to the given location.
MethodNotImplementedExceptionClass for a server exception caused when we recognize what the client is attempting to request, but postActiv does not currently support it.
ProfileNoAcctUriExceptionClass for a server exception caused by finding no URI associated with an account.
ConfigExceptionClass for a server exception caused by a malformed config.php
InvalidFilenameExceptionClass for a server exception caused by passing an illegal filename as a parameter.
InvalidUriExceptionClass for an exception when a URL is invalid.
PasswordHashExceptionClass for a server exception caused by password hashing to fail.
FeedSubExceptionClass for a server exception caused by the server being unable to process a feedsub properly.
OStatusShadowExceptionException indicating we’ve got a remote reference to a local user, not a remote user!
WebFingerReconstructionExceptionClass for a server exception cause when a WebFinger acct: URI can not be constructed using the data we have in a Profile.

ServerException

Class for server-side exceptions in postActiv

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

ServerException and descendant classes as well as the canonical error definitions

These classes represent various internal server errors that ususally are not fixable by the end user.

Since most exception classes share similar internals, the particulares are only documented where there’s a significant divergence worth noting.

PHP version

Tested with PHP 7

File Authors

Web

ServerException

Subclass of PHP Exception for server errors.  The user typically can’t fix these.

Summary
__constructConstructor for the exception, which by default will log the exception even if otherwise it’s caught.
__toStringReturn a string representation of the exception.

__construct

public function __construct( $message =  null,
 $code =  SERVER_EXCEPTION,
Exception $previous =  null,
 $severity =  LOG_ERR)

Constructor for the exception, which by default will log the exception even if otherwise it’s caught.

__toString

public function __toString()

Return a string representation of the exception.

AlreadyFulfilledException

Class for an exception when trying to do something that was probably already done.

This is a common case for example when remote sites are not up to date with our database.  For example subscriptions, where a remote user may be unsubscribed from our user, but they request it anyway.

This exception should be caught in a manner that lets the execution continue as if the desired action did what it was supposed to do.

UnsupportedMediaException

Class for a server exception caused by handling an unsupported media type, typically through an attachment/file upload.

UseFileAsThumbnailException

A specific variant of UnsupportedMediaException where we do not have a thumbnail generated for the given file.

UnknownUriException

Class for server exception caused by something specifying a URI that we cannot find or reach.

UnknownMimeExtensionException

Class for unknown MIME extension exception.  Thrown when we don’t know the file extension for a given MIME type.  This generally means that all files are accepted since if we have a list of known MIMEs then they have extensions coupled to them.

UnknownExtensionMimeException

Class for unknown extension MIME type exception.  Inverse of UnknownMimeExtension - error for when we know the extension but not the MIME type.

NoticeSaveException

Class for a server exception caused when a notice cannot be saved.

FileNotFoundException

Class for a server exception caused by being unable to find something we know should be stored locally.

NoResultException

Class for an exception when a database lookup returns no results

NoSuchUserException

Class for a server exception caused by a user lookup which fails.

NoSuchGroupException

Class for a server exception caused by a group lookup which fails.

NoQueueHandlerException

Class for a server exception caused by finding no queue handler for a given transport.  This likely is either a misconfiguration, or using a queue handler that doesn’t implement a transport the site is actively using.

NoProfileException

Parent class for an exception when a profile is missing.

UserNoProfileException

Class for an exception when the user profile is missing

Summary
getUserReturns the user with a missing profile.

getUser

protected function getUser()

Returns the user with a missing profile.

GroupNoProfileException

Basically UserNoProfileException, but for groups

Summary
getGroupReturns the group with a missing profile.

getGroup

protected function getGroup()

Returns the group with a missing profile.

NoParentNoticeException

Class for a server exception caused by a notice not having a parent.  This happens a lot, since many notices are not part of an existing convo, so I have put it in LOG_DEBUG severity level.

NoAvatarException

Class for a server exception caused by not being able to find the avatar for a given user.  A user might not have set one, so I put this at LOG_DEBUG severity since it can happen during normal operation.

NoObjectTypeException

Class for a server exception caused by a notice having no given type; most often this will happen because of an unrecognized activity verb.  Since this is not neccesarialy an error, but rather a federation incompatability, I have put it in LOG_WARNING severity.

NoRouteMapException

Class for a server exception caused by not finding a route map to the given location.  This happens in normal operation with 404 errors but can also happen with malfunctioning or misprogrammed plugins, so I have given it LOG_DEBUG severity.

MethodNotImplementedException

Class for a server exception caused when we recognize what the client is attempting to request, but postActiv does not currently support it.  This is caused internally by malfunctioning plugins, usually, so I have assigned it LOG_WARNING severity.

ProfileNoAcctUriException

Class for a server exception caused by finding no URI associated with an account.  This represents a malformed DB entry, usually.

ConfigException

Class for a server exception caused by a malformed config.php

InvalidFilenameException

Class for a server exception caused by passing an illegal filename as a parameter.  This represents likely a failure to save something, so I have assigned it a LOG_WARNING severity.

InvalidUriException

Class for an exception when a URL is invalid.  I put this in LOG_INFO since it can be useful to find federation errors in normal operation.

PasswordHashException

Class for a server exception caused by password hashing to fail.  Since this compromises the security of client accounts, I have assigned this LOG_CRITICAL severity.

FeedSubException

Class for a server exception caused by the server being unable to process a feedsub properly.  This is probably fairly integral, but doesn’t usually stop execution, so LOG_WARNING it is.  It will usually only happen when we have got the sub content, but it’s malformed in some way, so not an error per se, but definitely worth a warning.

OStatusShadowException

Exception indicating we’ve got a remote reference to a local user, not a remote user!

If we can ue a local profile after all, it’s available as $e->profile.  -mmn

Most of the time this can happen entirely innocently, especially with older versions of GNU social or StatusNet, but it is worth noting, so I have assigned it LOG_INFO severity.  -mb

WebFingerReconstructionException

Class for a server exception cause when a WebFinger acct: URI can not be constructed using the data we have in a Profile.

public function __construct( $message =  null,
 $code =  SERVER_EXCEPTION,
Exception $previous =  null,
 $severity =  LOG_ERR)
Constructor for the exception, which by default will log the exception even if otherwise it’s caught.
public function __toString()
Return a string representation of the exception.
protected function getUser()
Returns the user with a missing profile.
protected function getGroup()
Returns the group with a missing profile.