Skip to content

Commit eddd066

Browse files
author
Kirill Nesmeyanov
committed
Reorganize runtime exceptions
1 parent 2b88d25 commit eddd066

File tree

92 files changed

+1261
-1269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1261
-1269
lines changed

example/02.errors/01.custom-type-printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5+
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
56
use TypeLang\Mapper\Mapper;
67
use TypeLang\Mapper\Mapping\MapType;
7-
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
88

99
require __DIR__ . '/../../vendor/autoload.php';
1010

example/02.errors/02.extended-type-printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5+
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
56
use TypeLang\Mapper\Mapper;
67
use TypeLang\Mapper\Mapping\MapType;
7-
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
88
use TypeLang\Parser\Node\Stmt\NamedTypeNode;
99
use TypeLang\Printer\PrettyPrinter;
1010

example/02.errors/03.custom-path-printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5+
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
56
use TypeLang\Mapper\Mapper;
67
use TypeLang\Mapper\Mapping\MapType;
7-
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
88
use TypeLang\Mapper\Runtime\Value\SimpleValuePrinter;
99

1010
require __DIR__ . '/../../vendor/autoload.php';

example/02.errors/04.custom-value-printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5+
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
56
use TypeLang\Mapper\Mapper;
67
use TypeLang\Mapper\Mapping\MapType;
7-
use TypeLang\Mapper\Exception\Mapping\RuntimeException;
88
use TypeLang\Mapper\Runtime\Path\PathInterface;
99
use TypeLang\Mapper\Runtime\Path\PathPrinterInterface;
1010

example/03.types/02.custom-type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use TypeLang\Mapper\Exception\Mapping\InvalidValueException;
5+
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
66
use TypeLang\Mapper\Mapper;
77
use TypeLang\Mapper\Platform\DelegatePlatform;
88
use TypeLang\Mapper\Platform\StandardPlatform;

example/03.types/03.custom-type-template-arguments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use TypeLang\Mapper\Exception\Mapping\InvalidValueException;
5+
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
66
use TypeLang\Mapper\Mapper;
77
use TypeLang\Mapper\Platform\DelegatePlatform;
88
use TypeLang\Mapper\Platform\StandardPlatform;

src/Exception/Definition/DefinitionException.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
*/
1414
abstract class DefinitionException extends \InvalidArgumentException implements MapperExceptionInterface
1515
{
16-
/**
17-
* @var int
18-
*/
19-
protected const CODE_ERROR_LAST = 0x00;
20-
2116
public readonly Template $template;
2217

2318
public function __construct(

src/Exception/Definition/InternalTypeException.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
class InternalTypeException extends DefinitionException
1010
{
11-
/**
12-
* @var int
13-
*/
14-
public const CODE_ERROR_INTERNAL = 0x01 + parent::CODE_ERROR_LAST;
15-
16-
/**
17-
* @var int
18-
*/
19-
protected const CODE_ERROR_LAST = self::CODE_ERROR_INTERNAL;
20-
2111
public static function becauseInternalTypeErrorOccurs(
2212
TypeStatement $type,
2313
?string $message = null,
@@ -26,7 +16,6 @@ public static function becauseInternalTypeErrorOccurs(
2616
return new self(
2717
type: $type,
2818
template: $message ?? 'An error occurred while creating "{{type}}" type',
29-
code: self::CODE_ERROR_INTERNAL,
3019
previous: $previous,
3120
);
3221
}

src/Exception/Definition/PropertyTypeNotFoundException.php

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
class PropertyTypeNotFoundException extends TypeNotFoundException
1010
{
11-
/**
12-
* @var int
13-
*/
14-
public const CODE_ERROR_PROPERTY_TYPE_NOT_DEFINED = 0x01 + parent::CODE_ERROR_LAST;
15-
16-
/**
17-
* @var int
18-
*/
19-
protected const CODE_ERROR_LAST = self::CODE_ERROR_PROPERTY_TYPE_NOT_DEFINED;
20-
2111
/**
2212
* @param class-string $class
2313
* @param non-empty-string $property
@@ -33,26 +23,6 @@ public function __construct(
3323
parent::__construct($type, $template, $code, $previous);
3424
}
3525

36-
/**
37-
* @api
38-
*
39-
* @return class-string
40-
*/
41-
public function getClass(): string
42-
{
43-
return $this->class;
44-
}
45-
46-
/**
47-
* @api
48-
*
49-
* @return non-empty-string
50-
*/
51-
public function getProperty(): string
52-
{
53-
return $this->property;
54-
}
55-
5626
/**
5727
* @param class-string $class
5828
* @param non-empty-string $property
@@ -67,13 +37,31 @@ public static function becauseTypeOfPropertyNotDefined(
6737
class: $class,
6838
property: $property,
6939
type: $type,
70-
template: \sprintf(
71-
'Type "{{type}}" for property %s::$%s is not registered',
40+
template: \vsprintf('Type "{{type}}" for property %s::$%s is not registered', [
7241
$class,
7342
$property,
74-
),
75-
code: self::CODE_ERROR_PROPERTY_TYPE_NOT_DEFINED,
43+
]),
7644
previous: $previous,
7745
);
7846
}
47+
48+
/**
49+
* @api
50+
*
51+
* @return class-string
52+
*/
53+
public function getClass(): string
54+
{
55+
return $this->class;
56+
}
57+
58+
/**
59+
* @api
60+
*
61+
* @return non-empty-string
62+
*/
63+
public function getProperty(): string
64+
{
65+
return $this->property;
66+
}
7967
}

src/Exception/Definition/Shape/ShapeFieldException.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
*/
1313
abstract class ShapeFieldException extends ShapeFieldsException
1414
{
15-
/**
16-
* @var int
17-
*/
18-
protected const CODE_ERROR_LAST = parent::CODE_ERROR_LAST;
19-
2015
public function __construct(
2116
protected readonly FieldNode $field,
2217
TypeStatement $type,

0 commit comments

Comments
 (0)