Skip to content

Commit 7771bd4

Browse files
committed
Improve exception messages on AbstractModel
Amends 16d41eb
1 parent 16d41eb commit 7771bd4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Charcoal/Model/AbstractModel.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,22 @@ public function loadFromL10n($key, $value, array $langs)
368368

369369
$sth = $source->dbQuery($sql, $binds);
370370
if ($sth === false) {
371-
throw new PDOException('Could not load item.');
371+
throw new PDOException(sprintf(
372+
'Could not load model [%s] for localized column "%s" [%s]',
373+
get_class($this),
374+
$fieldName,
375+
(is_object($value) ? get_class($value) : (is_string($value) ? $value : gettype($value)))
376+
));
372377
}
373378

374379
$data = $sth->fetch(PDO::FETCH_ASSOC);
375380
if (!$data || !isset($data['_lang'])) {
376-
throw new PDOException('Could not load item.');
381+
throw new PDOException(sprintf(
382+
'Unable to retrieve model [%s] data for localized column "%s" [%s]',
383+
get_class($this),
384+
$fieldName,
385+
(is_object($value) ? get_class($value) : (is_string($value) ? $value : gettype($value)))
386+
));
377387
}
378388

379389
$lang = $data['_lang'];
@@ -481,7 +491,7 @@ protected function createSource()
481491

482492
if (!$sourceConfig) {
483493
throw new UnexpectedValueException(sprintf(
484-
'Can not create source for [%s]: invalid metadata (can not load source\'s configuration).',
494+
'Can not create source for model [%s]: Invalid metadata (can not load source\'s configuration)',
485495
get_class($this)
486496
));
487497
}

0 commit comments

Comments
 (0)