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
5 changes: 5 additions & 0 deletions src/Config/SQLite/ConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public function getName(): string
{
return 'sqlite';
}

public function formatExceptionMessage(string $message): string
{
return $message;
}
}
5 changes: 5 additions & 0 deletions src/Config/SQLite/FileConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ public function getSourceString(): string
{
return $this->database;
}

public function formatExceptionMessage(string $message): string
{
return \sprintf('(%s) %s', $this->database, $message);
}
}
5 changes: 5 additions & 0 deletions src/Config/SQLite/MemoryConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public function __construct(array $options = [])
{
parent::__construct(self::DATABASE_NAME, $options);
}

public function formatExceptionMessage(string $message): string
{
return $message;
}
}
7 changes: 6 additions & 1 deletion src/Driver/SQLite/SQLiteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Cycle\Database\Query\InsertQuery;
use Cycle\Database\Query\QueryBuilder;

/**
* @property SQLiteDriverConfig $config
*/
class SQLiteDriver extends Driver
{
/**
Expand Down Expand Up @@ -52,7 +55,9 @@ protected function mapException(\Throwable $exception, string $query): Statement
return new StatementException\ConstrainException($exception, $query);
}

return new StatementException($exception, $query);
return (new StatementException($exception, $query))->setMessage(
message: $this->config->connection->formatExceptionMessage($exception->getMessage()),
);
}

protected function setIsolationLevel(string $level): void
Expand Down
7 changes: 7 additions & 0 deletions src/Exception/StatementException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ public function getQuery(): string
{
return $this->query;
}

public function setMessage(string $message): self
{
$this->message = $message;

return $this;
}
}
Loading