```php
if (strpos($exception->getMessage(), 'Access denied for user') !== false ||
    strpos($exception->getMessage(), 'getaddrinfo failed: Name or service not known') !== false ||
    strpos($exception->getMessage(), 'getaddrinfo failed: nodename nor servname provided, or not known') !== false) {
    return DBALException::ERROR_ACCESS_DENIED;
}
```

Something like that.