mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
PermissionParser: Throw more specific exceptions
This commit is contained in:
parent
13178a47a5
commit
7245d15abe
@ -55,7 +55,7 @@ class PermissionParser{
|
||||
/**
|
||||
* @param bool|string $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws PermissionParserException
|
||||
*/
|
||||
public static function defaultFromString($value) : string{
|
||||
if(is_bool($value)){
|
||||
@ -70,7 +70,7 @@ class PermissionParser{
|
||||
return self::DEFAULT_STRING_MAP[$lower];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Unknown permission default name \"$value\"");
|
||||
throw new PermissionParserException("Unknown permission default name \"$value\"");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,6 +79,7 @@ class PermissionParser{
|
||||
*
|
||||
* @return Permission[][]
|
||||
* @phpstan-return array<string, list<Permission>>
|
||||
* @throws PermissionParserException
|
||||
*/
|
||||
public static function loadPermissions(array $data, string $default = self::DEFAULT_FALSE) : array{
|
||||
$result = [];
|
||||
@ -89,7 +90,7 @@ class PermissionParser{
|
||||
}
|
||||
|
||||
if(isset($entry["children"])){
|
||||
throw new \InvalidArgumentException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
||||
throw new PermissionParserException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
||||
}
|
||||
|
||||
if(isset($entry["description"])){
|
||||
|
31
src/permission/PermissionParserException.php
Normal file
31
src/permission/PermissionParserException.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\permission;
|
||||
|
||||
/**
|
||||
* Thrown by PermissionParser when it encounters data that it doesn't like.
|
||||
*/
|
||||
final class PermissionParserException extends \RuntimeException{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user