knuckleswtf / knuckleswtf/scribe

DatabaseTransactionHelpers swallows PDOException

Open
#781 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
2.3k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

### Scribe version

4.29.0

### PHP version

8.3.0

### Framework

Laravel

### Framework version

10.39.0

### Scribe config

```ruby
try_it_out.enabled => false
auth.enabled => true
auth.default => true
auth.placeholder => "{API_TOKEN}"
```

### What happened?

I've been trying to build my docs using GitHub actions and running into the [exception thrown here](https://github.com/knuckleswtf/scribe/blob/master/src/Extracting/DatabaseTransactionHelpers.php#L24-L32). The problem is that this hides the real error and makes every error look like it's a connection issue.

```php
try {
$driver->beginTransaction();
} catch (PDOException $e) {
throw new \Exception(
"Failed to connect to database connection '$connection'." .
" Is the database running?" .
" If you aren't using this database, remove it from the `database_connections_to_transact` config array."
);
}
```

In this instance I received an exception with the message `Failed to connect to the database connection 'pgsql'`. However the actual issue was that I hadn't run my database migrations prior to generating the docs.

I wonder if this thrown `Exception` should include the message from the `PDOException`, or instead don't catch the `PDOException`.

### Docs

- [X] I've checked [the docs](https://scribe.knuckles.wtf/laravel), the [troubleshooting guide](https://scribe.knuckles.wtf/laravel/troubleshooting), and [existing issues](https://github.com/knuckleswtf/scribe/issues?q=is%3Aissue+), but I didn't find a solution

Contributor guide

Open the contributing guide

Research direction

Start with src/Extracting/DatabaseTransactionHelpers.php:24-32 and reproduce the documentation build with migrations absent. Compare the reported PDOException with the wrapper exception and determine how failures should expose the underlying cause; done means the original error is no longer hidden and the relevant tests cover it.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.