Skip to content

Commit b577ed9

Browse files
committed
Write better error message
1 parent 3103388 commit b577ed9

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

internal/tests/testdata/basic_author/expected/QueriesImpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getAuthor(int $authorId): ?Author
4040
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
4141
$ret = [];
4242
if(count($results) != 1){
43-
throw new \Exception("NOT 1 ROW RETURNED");
43+
throw new \Exception('Expected exactly 1 row, but got ' . count($results));
4444
}
4545
foreach ($results as $row) {
4646
$ret[] = new Author($row["author_id"], $row["name"]);

internal/tests/testdata/datetime_immutable/expected/QueriesImpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getAuthorByCreatedAt(\DateTimeImmutable $createdAt): ?Author
4747
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
4848
$ret = [];
4949
if(count($results) != 1){
50-
throw new \Exception("NOT 1 ROW RETURNED");
50+
throw new \Exception('Expected exactly 1 row, but got ' . count($results));
5151
}
5252
foreach ($results as $row) {
5353
$ret[] = new Author($row["id"], $row["name"], $row["created_at"] == null ? null : new \DateTimeImmutable($row["created_at"]));

internal/tests/testdata/json_data/expected/QueriesImpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getAuthor(int $authorId): ?Author
5858
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
5959
$ret = [];
6060
if(count($results) != 1){
61-
throw new \Exception("NOT 1 ROW RETURNED");
61+
throw new \Exception('Expected exactly 1 row, but got ' . count($results));
6262
}
6363
foreach ($results as $row) {
6464
$ret[] = new Author($row["author_id"], json_decode($row["data"], true) ?? []);

internal/tmpl/query_impl.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final readonly class QueriesImpl implements Queries {
3535
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
3636
$ret = [];
3737
if(count($results) != 1){
38-
throw new \Exception("NOT 1 ROW RETURNED");
38+
throw new \Exception('Expected exactly 1 row, but got ' . count($results));
3939
}
4040
foreach ($results as $row) {
4141
$ret[] = new {{.Ret.Type}}({{.Ret.ResultSet}});

0 commit comments

Comments
 (0)