Skip to content
This repository was archived by the owner on Dec 19, 2022. It is now read-only.

Commit f7184ba

Browse files
author
Seif Kamal
committed
Make error messages more consistent
1 parent e2f0397 commit f7184ba

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

docs/use-case.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class StatsController {
214214
- Easy to read
215215
- Easy to scale
216216
- Automatic, customisable error messaging; Here's an example:
217-
> Struct 'Event' failed validation: Invalid value for property 'date'
217+
> Event failed validation. Invalid value for property: 'date'
218218
- All possible parameters and their validation rules are documented in code, in the method itself
219219
- Extensible - `Struct`s are essentially arrays of `callable`s (and other `Struct`s), so they can
220220
easily be worked into systems and be extended accordingly

src/Exception/InvalidValueException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class InvalidValueException extends \Exception
66
{
77
public function __construct(string $property)
88
{
9-
parent::__construct("Invalid value for property '{$property}'");
9+
parent::__construct("Invalid value for property: '{$property}'");
1010
}
1111
}

src/Exception/MissingPropertyException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class MissingPropertyException extends \Exception
66
{
77
public function __construct(string $property)
88
{
9-
parent::__construct("missing value for '{$property}'");
9+
parent::__construct("Missing value for property: '{$property}'");
1010
}
1111
}

src/Exception/StructValidationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class StructValidationException extends \Exception
99
public function __construct(Struct $struct, \Throwable $reason)
1010
{
1111
parent::__construct(
12-
"Struct '{$struct->name()}' failed validation: {$reason->getMessage()}",
12+
"{$struct->name()} failed validation. {$reason->getMessage()}",
1313
0,
1414
$reason
1515
);

src/Exception/UnexpectedPropertyException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class UnexpectedPropertyException extends \Exception
77
public function __construct(string ...$properties)
88
{
99
parent::__construct(sprintf(
10-
"Unexpected %s '%s'",
10+
"Unexpected %s: '%s'",
1111
count($properties) === 1 ? 'property' : 'properties',
1212
implode(', ', $properties)
1313
));

0 commit comments

Comments
 (0)