Skip to content

Commit 0503bde

Browse files
committed
Use \Error inside ::from()
1 parent ce24ceb commit 0503bde

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/php/lang/ast/emit/PHP.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected function emitEnum($result, $enum) {
387387
}');
388388
$result->out->write('public static function from($value) {
389389
if ($r= self::$values[$value] ?? null) return $r;
390-
throw new \Exception(\util\Objects::stringOf($value)." is not a valid backing value for enum \"".self::class."\"");
390+
throw new \Error(\util\Objects::stringOf($value)." is not a valid backing value for enum \"".self::class."\"");
391391
}');
392392
} else {
393393
$result->out->write('public $name;');

src/test/php/lang/ast/unittest/emit/EnumTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function run() {
103103
try {
104104
self::from("illegal");
105105
throw new IllegalStateException("No exception raised");
106-
} catch (\Throwable $expected) {
106+
} catch (\Error $expected) {
107107
return $expected->getMessage();
108108
}
109109
}

0 commit comments

Comments
 (0)