[LIB_REFACTOR] Moving files into separate semantic categories
This commit is contained in:
51
lib/exceptions/alreadyfulfilledexception.php
Normal file
51
lib/exceptions/alreadyfulfilledexception.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
* Copyright (C) 2014, Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Parent 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 is usually caught in a manner that lets the execution
|
||||
* continue _as if_ the desired action did what it was supposed to do.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://gnu.io/
|
||||
*/
|
||||
|
||||
class AlreadyFulfilledException extends ServerException
|
||||
{
|
||||
public function __construct($msg=null)
|
||||
{
|
||||
if ($msg === null) {
|
||||
// TRANS: Exception text when attempting to perform something which seems already done.
|
||||
$msg = _('Trying to do something that was already done.');
|
||||
}
|
||||
|
||||
parent::__construct($msg, 409);
|
||||
}
|
||||
}
|
59
lib/exceptions/authorizationexception.php
Normal file
59
lib/exceptions/authorizationexception.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* An exception for authorization errors
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* An exception for authorization issues
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class AuthorizationException extends ClientException
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $message Message for the exception
|
||||
*/
|
||||
public function __construct($message=null)
|
||||
{
|
||||
parent::__construct($message, 403);
|
||||
}
|
||||
}
|
55
lib/exceptions/clientexception.php
Normal file
55
lib/exceptions/clientexception.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for a client exception (user error)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for client exceptions
|
||||
*
|
||||
* Subclass of PHP Exception for user errors.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ClientException extends Exception
|
||||
{
|
||||
public function __construct($message = null, $code = 400) {
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
|
||||
// custom string representation of object
|
||||
public function __toString() {
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
22
lib/exceptions/configexception.php
Normal file
22
lib/exceptions/configexception.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for configuration exceptions
|
||||
*
|
||||
* Subclass of ServerException for when the site's configuration is malformed.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license https://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link https://gnu.io/social
|
||||
*/
|
||||
|
||||
class ConfigException extends ServerException
|
||||
{
|
||||
public function __construct($message=null) {
|
||||
parent::__construct($message, 500);
|
||||
}
|
||||
}
|
34
lib/exceptions/emailexception.php
Normal file
34
lib/exceptions/emailexception.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when there is something wrong with sending email
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class EmailException extends Exception
|
||||
{
|
||||
}
|
41
lib/exceptions/emptypkeyvalueexception.php
Normal file
41
lib/exceptions/emptypkeyvalueexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a database lookup returns no results
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class EmptyPkeyValueException extends ServerException
|
||||
{
|
||||
public function __construct($called_class, $key=null)
|
||||
{
|
||||
// FIXME: translate the 'not specified' case?
|
||||
parent::__construct(sprintf(_('Empty primary key (%1$s) value was given to query for a "%2$s" object'),
|
||||
is_null($key) ? 'not specified' : _ve($key),
|
||||
$called_class));
|
||||
}
|
||||
}
|
42
lib/exceptions/filenotfoundexception.php
Normal file
42
lib/exceptions/filenotfoundexception.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a database lookup returns no results
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class FileNotFoundException extends ServerException
|
||||
{
|
||||
public $path = null;
|
||||
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
common_debug('File not found exception for: '._ve($this->path));
|
||||
parent::__construct(_('File not found in filesystem.'), 404);
|
||||
}
|
||||
}
|
15
lib/exceptions/filenotstoredlocallyexception.php
Normal file
15
lib/exceptions/filenotstoredlocallyexception.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class FileNotStoredLocallyException extends ServerException
|
||||
{
|
||||
public $file = null;
|
||||
|
||||
public function __construct(File $file)
|
||||
{
|
||||
$this->file = $file;
|
||||
common_debug('Requested local URL for a file that is not stored locally with id=='._ve($this->file->getID()));
|
||||
parent::__construct(_('Requested local URL for a file that is not stored locally.'));
|
||||
}
|
||||
}
|
74
lib/exceptions/groupnoprofileexception.php
Normal file
74
lib/exceptions/groupnoprofileexception.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when the group profile is missing
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when the group profile is missing
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GroupNoProfileException extends NoProfileException
|
||||
{
|
||||
protected $group = null;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param User_group $user User_group that's missing a profile
|
||||
*/
|
||||
|
||||
public function __construct(User_group $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
|
||||
// TRANS: Exception text shown when no profile can be found for a group.
|
||||
// TRANS: %1$s is a group nickname, $2$d is a group profile_id (number).
|
||||
$message = sprintf(_('Group "%1$s" (%2$d) has no profile record.'),
|
||||
$group->nickname, $group->getID());
|
||||
|
||||
parent::__construct($group->profile_id, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for user
|
||||
*
|
||||
* @return User_group the group that triggered this exception
|
||||
*/
|
||||
|
||||
public function getGroup()
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
}
|
52
lib/exceptions/invalidfilenameexception.php
Normal file
52
lib/exceptions/invalidfilenameexception.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a filename is invalid
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license https://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://gnu.io/social
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a filename is invalid
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license https://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://gnu.io/social
|
||||
*/
|
||||
|
||||
class InvalidFilenameException extends ServerException
|
||||
{
|
||||
public $filename = null;
|
||||
|
||||
public function __construct($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
// We could log an entry here with the search parameters
|
||||
parent::__construct(_('Invalid filename.'));
|
||||
}
|
||||
}
|
52
lib/exceptions/invalidurlexception.php
Normal file
52
lib/exceptions/invalidurlexception.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a URL is invalid
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a URL is invalid
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class InvalidUrlException extends ServerException
|
||||
{
|
||||
public $url = null;
|
||||
|
||||
public function __construct($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
// We could log an entry here with the search parameters
|
||||
parent::__construct(_('Invalid URL.'));
|
||||
}
|
||||
}
|
50
lib/exceptions/methodnotimplementedexception.php
Normal file
50
lib/exceptions/methodnotimplementedexception.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for an exception when a method is not implemented
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for an exception when a local user is not found by certain criteria
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class MethodNotImplementedException extends ServerException
|
||||
{
|
||||
public function __construct($method)
|
||||
{
|
||||
parent::__construct(sprintf(_('Method %s not implemented'), $method));
|
||||
}
|
||||
}
|
41
lib/exceptions/noavatarexception.php
Normal file
41
lib/exceptions/noavatarexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when unable to retrieve or resize a profile's avatar.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoAvatarException extends NoResultException
|
||||
{
|
||||
public $target;
|
||||
|
||||
public function __construct(Profile $target, Avatar $obj)
|
||||
{
|
||||
$this->target = $target;
|
||||
parent::__construct($obj);
|
||||
}
|
||||
}
|
43
lib/exceptions/nohttpresponseexception.php
Normal file
43
lib/exceptions/nohttpresponseexception.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when an HTTP request gets no response (DNS failure etc.)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
// Can't extend HTTP_Request2_Exception since it requires an HTTP status code which we didn't get
|
||||
class NoHttpResponseException extends HTTP_Request2_ConnectionException
|
||||
{
|
||||
public $url; // target URL
|
||||
|
||||
public function __construct($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
// We could log an entry here with the search parameters
|
||||
parent::__construct(sprintf(_('No HTTP response from URL %s.'), _ve($url)), self::READ_ERROR);
|
||||
}
|
||||
}
|
41
lib/exceptions/noobjecttypeexception.php
Normal file
41
lib/exceptions/noobjecttypeexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a database lookup returns no results
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoObjectTypeException extends ServerException
|
||||
{
|
||||
public $stored; // The object with query that gave no results
|
||||
|
||||
public function __construct(Notice $stored)
|
||||
{
|
||||
$this->stored = $stored;
|
||||
parent::__construct(sprintf(_('Notice has no object type.')));
|
||||
}
|
||||
}
|
41
lib/exceptions/noparentnoticeexception.php
Normal file
41
lib/exceptions/noparentnoticeexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a database lookup returns no results
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoParentNoticeException extends ServerException
|
||||
{
|
||||
public $notice; // The notice which has no parent
|
||||
|
||||
public function __construct(Notice $notice)
|
||||
{
|
||||
$this->notice = $notice;
|
||||
parent::__construct(sprintf(_('No parent for notice with ID "%s".'), $this->notice->id));
|
||||
}
|
||||
}
|
58
lib/exceptions/noprofileexception.php
Normal file
58
lib/exceptions/noprofileexception.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Parent class for an exception when a profile is missing
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Parent class for an exception when a profile is missing
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class NoProfileException extends ServerException
|
||||
{
|
||||
public $profile_id = null;
|
||||
|
||||
public function __construct($profile_id, $msg=null)
|
||||
{
|
||||
$this->profile_id = $profile_id;
|
||||
|
||||
if ($msg === null) {
|
||||
// TRANS: Exception text shown when no profile can be found for a user.
|
||||
// TRANS: %u is a profile ID (number).
|
||||
$msg = sprintf(_('There is no profile with id==%u'), $this->profile_id);
|
||||
}
|
||||
|
||||
parent::__construct($msg, 404);
|
||||
}
|
||||
}
|
41
lib/exceptions/noqueuehandlerexception.php
Normal file
41
lib/exceptions/noqueuehandlerexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when there is no queuehandler for this transport type
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoQueueHandlerException extends ServerException
|
||||
{
|
||||
public $transport; // The object with query that gave no results
|
||||
|
||||
public function __construct($transport)
|
||||
{
|
||||
$this->transport = $transport;
|
||||
parent::__construct(sprintf(_('No queue handler found for transport %s.'), _ve($this->transport)));
|
||||
}
|
||||
}
|
42
lib/exceptions/noresultexception.php
Normal file
42
lib/exceptions/noresultexception.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a database lookup returns no results
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoResultException extends ServerException
|
||||
{
|
||||
public $obj; // The object with query that gave no results
|
||||
|
||||
public function __construct(Memcached_DataObject $obj)
|
||||
{
|
||||
$this->obj = $obj;
|
||||
// We could log an entry here with the search parameters
|
||||
parent::__construct(sprintf(_('No result found on %s lookup.'), get_class($obj)));
|
||||
}
|
||||
}
|
41
lib/exceptions/noroutemapexception.php
Normal file
41
lib/exceptions/noroutemapexception.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when route mapping failed (path to Action)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoRouteMapException extends Exception
|
||||
{
|
||||
public $path; // The object with query that gave no results
|
||||
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
parent::__construct(sprintf(_('Could not find a handler for the given path %s.'), _ve($this->path)));
|
||||
}
|
||||
}
|
67
lib/exceptions/nosuchgroupexception.php
Normal file
67
lib/exceptions/nosuchgroupexception.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for an exception when a User_group is not found by certain criteria
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a local user is not found by certain criteria
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class NoSuchGroupException extends ServerException
|
||||
{
|
||||
public $data = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param array $data User_group search criteria
|
||||
*/
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
// filter on unique keys for User_group entries
|
||||
foreach(array('id', 'profile_id') as $key) {
|
||||
if (isset($data[$key]) && !empty($data[$key])) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// Here we could log the failed lookup
|
||||
|
||||
parent::__construct(_('No such group found.'));
|
||||
}
|
||||
}
|
67
lib/exceptions/nosuchuserexception.php
Normal file
67
lib/exceptions/nosuchuserexception.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for an exception when a local user is not found by certain criteria
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a local user is not found by certain criteria
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class NoSuchUserException extends ServerException
|
||||
{
|
||||
public $data = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param array $data user search criteria
|
||||
*/
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
// filter on unique keys for local users
|
||||
foreach(array('id', 'email', 'nickname') as $key) {
|
||||
if (isset($data[$key]) && !empty($data[$key])) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// Here we could log the failed lookup
|
||||
|
||||
parent::__construct(_('No such user found.'));
|
||||
}
|
||||
}
|
31
lib/exceptions/nouploadedmediaexception.php
Normal file
31
lib/exceptions/nouploadedmediaexception.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Parent class for an exception when a POST upload does not contain a file.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://gnu.io/
|
||||
*/
|
||||
|
||||
class NoUploadedMediaException extends ClientException
|
||||
{
|
||||
public $fieldname = null;
|
||||
|
||||
public function __construct($fieldname, $msg=null)
|
||||
{
|
||||
$this->fieldname = $fieldname;
|
||||
|
||||
if ($msg === null) {
|
||||
// TRANS: Exception text shown when no uploaded media was provided in POST
|
||||
// TRANS: %s is the HTML input field name.
|
||||
$msg = sprintf(_('There is no uploaded media for input field "%s".'), $this->fieldname);
|
||||
}
|
||||
|
||||
parent::__construct($msg, 400);
|
||||
}
|
||||
}
|
42
lib/exceptions/nouriexception.php
Normal file
42
lib/exceptions/nouriexception.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
*
|
||||
* class for when an object that's supposed to have a URI is missing it
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class NoUriException extends ServerException
|
||||
{
|
||||
var $object = null;
|
||||
|
||||
public function __construct(Managed_DataObject $object)
|
||||
{
|
||||
$this->object = $object;
|
||||
$msg = get_class($object) . ' does not have a URI.';
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
44
lib/exceptions/passwordhashexception.php
Normal file
44
lib/exceptions/passwordhashexception.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when password hashing was unsuccessful
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class PasswordHashException extends ServerException
|
||||
{
|
||||
public $obj; // The object with query that gave no results
|
||||
|
||||
public function __construct($msg=null, $code=500)
|
||||
{
|
||||
if ($msg === null) {
|
||||
$msg = _('Password hashing failed.');
|
||||
}
|
||||
|
||||
parent::__construct($msg, $code);
|
||||
}
|
||||
}
|
31
lib/exceptions/privatestreamexception.php
Normal file
31
lib/exceptions/privatestreamexception.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* An exception for private streams
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
*/
|
||||
|
||||
class PrivateStreamException extends AuthorizationException
|
||||
{
|
||||
var $owner = null; // owner of the private stream
|
||||
var $reader = null; // reader, may be null if not logged in
|
||||
|
||||
public function __construct(Profile $owner, Profile $reader=null)
|
||||
{
|
||||
$this->owner = $owner;
|
||||
$this->reader = $reader;
|
||||
|
||||
// TRANS: Message when a private stream attemps to be read by unauthorized third party.
|
||||
$msg = sprintf(_m('This stream is protected and only authorized subscribers may see its contents.'));
|
||||
|
||||
// If $reader is a profile, authentication has been made but still not accepted (403),
|
||||
// otherwise authentication may give access to this resource (401).
|
||||
parent::__construct($msg, ($reader instanceof Profile ? 403 : 401));
|
||||
}
|
||||
}
|
58
lib/exceptions/profilenoaccturiexception.php
Normal file
58
lib/exceptions/profilenoaccturiexception.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when a Profile has no discernable acct: URI
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Parent class for an exception when a profile is missing
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ProfileNoAcctUriException extends ServerException
|
||||
{
|
||||
public $profile = null;
|
||||
|
||||
public function __construct(Profile $profile, $msg=null)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
|
||||
if ($msg === null) {
|
||||
// TRANS: Exception text shown when no profile can be found for a user.
|
||||
// TRANS: %1$s is a user nickname, $2$d is a user ID (number).
|
||||
$msg = sprintf(_('Could not get an acct: URI for profile with id==%u'), $this->profile->id);
|
||||
}
|
||||
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
55
lib/exceptions/serverexception.php
Normal file
55
lib/exceptions/serverexception.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for a server exception (user error)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for server exceptions
|
||||
*
|
||||
* Subclass of PHP Exception for server errors. The user typically can't fix these.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ServerException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 500) {
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
26
lib/exceptions/unknownextensionmimeexception.php
Normal file
26
lib/exceptions/unknownextensionmimeexception.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for unknown extension MIME type exception
|
||||
*
|
||||
* Thrown when we don't know the MIME type for a given file extension.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.html
|
||||
* @link https://gnu.io/social
|
||||
*/
|
||||
|
||||
class UnknownExtensionMimeException extends ServerException
|
||||
{
|
||||
public function __construct($ext)
|
||||
{
|
||||
// TRANS: We accept the file type (we probably just accept all files)
|
||||
// TRANS: but don't know the file extension for it. %1$s is the extension.
|
||||
$msg = sprintf(_('Unknown MIME type for file extension: %1$s'), _ve($ext));
|
||||
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
27
lib/exceptions/unknownmimeextensionexception.php
Normal file
27
lib/exceptions/unknownmimeextensionexception.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.html
|
||||
* @link https://gnu.io/social
|
||||
*/
|
||||
|
||||
class UnknownMimeExtensionException extends ServerException
|
||||
{
|
||||
public function __construct($mimetype)
|
||||
{
|
||||
// TRANS: We accept the file type (we probably just accept all files)
|
||||
// TRANS: but don't know the file extension for it.
|
||||
$msg = sprintf(_('Supported mimetype but unknown extension relation: %1$s'), _ve($mimetype));
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
49
lib/exceptions/unknownuriexception.php
Normal file
49
lib/exceptions/unknownuriexception.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
*
|
||||
* class for exception thrown when a lookup by URI fails
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class UnknownUriException extends ServerException
|
||||
{
|
||||
public $object_uri = null;
|
||||
|
||||
public function __construct($object_uri, $msg=null)
|
||||
{
|
||||
$this->object_uri = $object_uri;
|
||||
|
||||
if ($msg === null) {
|
||||
// TRANS: Exception text shown when no object found with certain URI
|
||||
// TRANS: %s is the URI.
|
||||
$msg = sprintf(_('No object found with URI "%s"'), $this->object_uri);
|
||||
common_debug(__CLASS__ . ': ' . $msg);
|
||||
}
|
||||
|
||||
parent::__construct($msg, 404);
|
||||
}
|
||||
}
|
39
lib/exceptions/unsupportedmediaexception.php
Normal file
39
lib/exceptions/unsupportedmediaexception.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
*
|
||||
* class for an exception when a File is of unsupported media type
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class UnsupportedMediaException extends ServerException
|
||||
{
|
||||
public function __construct($msg, $path=null)
|
||||
{
|
||||
//common_debug(sprintf('UnsupportedMediaException "%1$s". File path (if given): "%2$s"', $msg, $path));
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
42
lib/exceptions/usefileasthumbnailexception.php
Normal file
42
lib/exceptions/usefileasthumbnailexception.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
*
|
||||
* class for an exception when a thumbnail has not been generated from a File
|
||||
* object and the intention is to use the original File instead.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link https://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class UseFileAsThumbnailException extends UnsupportedMediaException
|
||||
{
|
||||
public $file = null;
|
||||
|
||||
public function __construct(File $file)
|
||||
{
|
||||
$this->file = $file;
|
||||
parent::__construct('Thumbnail not generated', $this->file->getPath());
|
||||
}
|
||||
}
|
74
lib/exceptions/usernoprofileexception.php
Normal file
74
lib/exceptions/usernoprofileexception.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when the user profile is missing
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: 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/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when the user profile is missing
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class UserNoProfileException extends NoProfileException
|
||||
{
|
||||
protected $user = null;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param User $user User that's missing a profile
|
||||
*/
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
// TRANS: Exception text shown when no profile can be found for a user.
|
||||
// TRANS: %1$s is a user nickname, $2$d is a user ID (number).
|
||||
$message = sprintf(_('User %1$s (%2$d) has no profile record.'),
|
||||
$user->nickname, $user->id);
|
||||
|
||||
parent::__construct($user->id, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for user
|
||||
*
|
||||
* @return User the user that triggered this exception
|
||||
*/
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user