# yatra/3.0.13/app/Exceptions/DatabaseException.php

Yatra – Travel Booking &amp; Tour Operator Software, version 3.0.13. 39 lines.

- Page: https://pluginprobe.com/plugins/yatra/3.0.13/code/app/Exceptions/DatabaseException.php
- Raw: https://pluginprobe.com/plugins/yatra/3.0.13/raw/app/Exceptions/DatabaseException.php
- Modified: 2026-04-14T03:47:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yatra/3.0.13/code/app/Exceptions/DatabaseException.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Yatra\Exceptions;

/**
 * Database Exception
 * 
 * Thrown when database operations fail
 */
class DatabaseException extends YatraException
{
    protected string $errorCode = 'database_error';

    public function __construct(string $message = 'Database operation failed', string $query = '', ?\Exception $previous = null)
    {
        $context = [];
        if (!empty($query)) {
            $context['query'] = $query;
        }
        
        parent::__construct($message, 500, $previous, $context);
    }

    /**
     * Create from wpdb error
     */
    public static function fromWpdbError(string $query = '', string $error = ''): self
    {
        $message = 'Database query failed';
        if (!empty($error)) {
            $message .= ': ' . $error;
        }
        
        return new self($message, $query);
    }
}

```
