Added extra Exceptions

This commit is contained in:
Shoghi Cervantes
2014-10-28 21:07:12 +01:00
parent b6f7ee20fc
commit 8c4faa8622
37 changed files with 215 additions and 87 deletions

View File

@ -24,6 +24,7 @@ namespace pocketmine\permission;
use pocketmine\event\Timings;
use pocketmine\plugin\Plugin;
use pocketmine\Server;
use pocketmine\utils\PluginException;
class PermissibleBase implements Permissible{
/** @var ServerOperator */
@ -72,7 +73,7 @@ class PermissibleBase implements Permissible{
*/
public function setOp($value){
if($this->opable === null){
throw new \Exception("Cannot change op value as no ServerOperator is set");
throw new \LogicException("Cannot change op value as no ServerOperator is set");
}else{
$this->opable->setOp($value);
}
@ -120,13 +121,13 @@ class PermissibleBase implements Permissible{
*
* @return PermissionAttachment
*
* @throws \Exception
* @throws PluginException
*/
public function addAttachment(Plugin $plugin, $name = null, $value = null){
if($plugin === null){
throw new \Exception("Plugin cannot be null");
throw new PluginException("Plugin cannot be null");
}elseif(!$plugin->isEnabled()){
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
}
$result = new PermissionAttachment($plugin, $this->parent);
@ -147,7 +148,7 @@ class PermissibleBase implements Permissible{
*/
public function removeAttachment(PermissionAttachment $attachment){
if($attachment === null){
throw new \Exception("Attachment cannot be null");
throw new \InvalidStateException("Attachment cannot be null");
}
if(isset($this->attachments[spl_object_hash($attachment)])){

View File

@ -225,7 +225,7 @@ class Permission{
if($value !== null){
$default = $value;
}else{
throw new \Exception("'default' key contained unknown value");
throw new \InvalidStateException("'default' key contained unknown value");
}
}
@ -240,7 +240,7 @@ class Permission{
$children[$k] = true;
}
}else{
throw new \Exception("'children' key is of wrong type");
throw new \InvalidStateException("'children' key is of wrong type");
}
}

View File

@ -22,6 +22,7 @@
namespace pocketmine\permission;
use pocketmine\plugin\Plugin;
use pocketmine\utils\PluginException;
class PermissionAttachment{
/** @var PermissionRemovedExecutor */
@ -42,11 +43,11 @@ class PermissionAttachment{
* @param Plugin $plugin
* @param Permissible $permissible
*
* @throws \Exception
* @throws PluginException
*/
public function __construct(Plugin $plugin, Permissible $permissible){
if(!$plugin->isEnabled()){
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
}
$this->permissible = $permissible;

View File

@ -41,11 +41,11 @@ class PermissionAttachmentInfo{
* @param PermissionAttachment $attachment
* @param bool $value
*
* @throws \Exception
* @throws \InvalidStateException
*/
public function __construct(Permissible $permissible, $permission, $attachment, $value){
if($permission === null){
throw new \Exception("Permission may not be null");
throw new \InvalidStateException("Permission may not be null");
}
$this->permissible = $permissible;