Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Transaction/AutoTransact.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public function write(Mapper $mapper, string $method, Record $record) : void
$this->commit();
} catch (Exception $e) {
$this->rollBack();
$c = get_class($e);
throw new $c($e->getMessage(), $e->getCode(), $e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think probably casting to int will help here.

public __construct ([ string $message = "" [, int $code = 0 [, Throwable $previous = NULL ]]] )

taken from https://www.php.net/manual/en/exception.construct.php .

So the order of exception seems not changing. Also if this code is removed, that may affect other parts for this can become a BC break for people who rely on multiple exception. ( Just a thought )

throw $e;
}
}
}
3 changes: 1 addition & 2 deletions tests/Transaction/AutoTransactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ public function testWrite()
$employee->id = '999';
$this->atlas->persist($employee);
} catch (Exception $e) {
$previous = $e->getPrevious();
$this->assertSame(
$previous->getMessage(),
$e->getMessage(),
"Primary key value for 'id' changed"
);
}
Expand Down