Skip to content

Commit

Permalink
Better error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
fireproofsocks committed Nov 20, 2014
1 parent 906bea3 commit c577d15
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 2 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modx_utils.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

167 changes: 167 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions firehose.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function add_records($args) {
global $modx;
for ($i=1; $i <= $args['count'] ; $i++) {
$obj = $modx->newObject($args['classname']);
$obj->fromArray($args);
$obj->fromArray($args); // <--- throw everything at the wall... only real properties should stick
switch ($args['classname']) {
case 'modResource':
// Set the things that need to be unique
Expand Down Expand Up @@ -70,7 +70,14 @@ function add_records($args) {
break;
}
if (!$obj->save()) {
print message("Failed to add a {$args['classname']} Record",'ERROR');
$summary = array();
$validator = $obj->getValidator();
if ($validator->hasMessages()) {
foreach ($validator->getMessages() as $message) {
$summary[] = sprintf("\t- field: %s -- \"%s\"\n", $message['field'], $message['message']);
}
}
print message("Failed to add a {$args['classname']} Record\n".implode("\n",$summary),'ERROR');
}
}
}
Expand Down

0 comments on commit c577d15

Please sign in to comment.