1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +01:00

Make nonscalar field saves raise a more useful exception from LiskDAO

Summary:
If you do something like this:

  // Missing $user->getPHID()!
  $object->setUserPHID($user)->save();

...you get a very unhelpful exception:

  Expected a scalar or null for %s conversion. Query: %s

This doesn't give you any hints about what's wrong. Instead, provide a more useful exception:

  Unable to insert or update object of class DifferentialRevision, field 'title' has a nonscalar value.

Test Plan: {F87614}

Reviewers: hach-que, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7725
This commit is contained in:
epriestley 2013-12-06 15:47:40 -08:00
parent f69793184e
commit 9d474452f9

View file

@ -1244,7 +1244,17 @@ abstract class LiskDAO {
$columns = array_keys($data);
foreach ($data as $key => $value) {
$data[$key] = qsprintf($conn, '%ns', $value);
try {
$data[$key] = qsprintf($conn, '%ns', $value);
} catch (AphrontQueryParameterException $parameter_exception) {
throw new PhutilProxyException(
pht(
"Unable to insert or update object of class %s, field '%s' ".
"has a nonscalar value.",
get_class($this),
$key),
$parameter_exception);
}
}
$data = implode(', ', $data);