Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/storage/lisk/PhabricatorDataNotAttachedException.php
12241 views
1
<?php
2
3
final class PhabricatorDataNotAttachedException extends Exception {
4
5
public function __construct($object) {
6
$stack = debug_backtrace();
7
8
// Shift off `PhabricatorDataNotAttachedException::__construct()`.
9
array_shift($stack);
10
// Shift off `PhabricatorLiskDAO::assertAttached()`.
11
array_shift($stack);
12
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}()");
19
}
20
}
21
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()'));
33
}
34
35
}
36
37