Skip to content

Commit ff5bea0

Browse files
committed
feat: introduce customizable format in GenericErrorFormatter
1 parent 6932cdf commit ff5bea0

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/Formatter/GenericErrorFormatter.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,33 @@
99

1010
final class GenericErrorFormatter extends AbstractErrorFormatter
1111
{
12+
private array $format = [
13+
'message' => '{title}',
14+
'status' => '{status_code}',
15+
'code' => '{code}',
16+
];
17+
1218
protected function createProblem(\Throwable $exception): Problem
1319
{
1420
return GenericProblem::createFromThrowable($exception);
1521
}
1622

1723
protected function getFormat(): array
1824
{
19-
$format = [
20-
'message' => '{title}',
21-
'status' => '{status_code}',
22-
'code' => '{code}',
23-
];
25+
$format = $this->format;
2426

2527
if ($this->debug) {
2628
$format['debug'] = '{debug}';
2729
}
2830

2931
return $format;
3032
}
33+
34+
/**
35+
* @param array<string, mixed> $format
36+
*/
37+
public function setFormat(array $format): void
38+
{
39+
$this->format = $format;
40+
}
3141
}

0 commit comments

Comments
 (0)