Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / storage / lisk / PhabricatorDataNotAttachedException.php
blob6f25c4d5536b7f06c6dc632b91fc21d819ee5e72
1 <?php
3 final class PhabricatorDataNotAttachedException extends Exception {
5 public function __construct($object) {
6 $stack = debug_backtrace();
8 // Shift off `PhabricatorDataNotAttachedException::__construct()`.
9 array_shift($stack);
10 // Shift off `PhabricatorLiskDAO::assertAttached()`.
11 array_shift($stack);
13 $frame = head($stack);
14 $via = null;
15 if (is_array($frame)) {
16 $method = idx($frame, 'function');
17 if (preg_match('/^get[A-Z]/', $method)) {
18 $via = ' '.pht('(via %s)', "{$method}()");
22 parent::__construct(
23 pht(
24 "Attempting to access attached data on %s, but the data is not ".
25 "actually attached. Before accessing attachable data on an object, ".
26 "you must load and attach it.\n\n".
27 "Data is normally attached by calling the corresponding %s method on ".
28 "the Query class when the object is loaded. You can also call the ".
29 "corresponding %s method explicitly.",
30 get_class($object).$via,
31 'needX()',
32 'attachX()'));