PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / app / Exceptions / DatabaseException.php

DatabaseException.php in Yatra – Travel Booking & Tour Operator Software trunk, at app/Exceptions/DatabaseException.php

39 lines 879 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Exceptions;
6
7 /**
8 * Database Exception
9 *
10 * Thrown when database operations fail
11 */
12 class DatabaseException extends YatraException
13 {
14 protected string $errorCode = 'database_error';
15
16 public function __construct(string $message = 'Database operation failed', string $query = '', ?\Exception $previous = null)
17 {
18 $context = [];
19 if (!empty($query)) {
20 $context['query'] = $query;
21 }
22
23 parent::__construct($message, 500, $previous, $context);
24 }
25
26 /**
27 * Create from wpdb error
28 */
29 public static function fromWpdbError(string $query = '', string $error = ''): self
30 {
31 $message = 'Database query failed';
32 if (!empty($error)) {
33 $message .= ': ' . $error;
34 }
35
36 return new self($message, $query);
37 }
38 }
39