Skip to content

Commit

Permalink
fixed error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bjendres committed Apr 20, 2017
1 parent 45c0b24 commit 23762eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 15 additions & 6 deletions CMRF_Drupal/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Call extends AbstractCall {

public static function createNew($connector_id, $core, $entity, $action, $parameters, $options, $callback) {
$call = new Call($core, $connector_id);

// compile request
$call->request = $call->compileRequest($parameters, $options);
$call->request['entity'] = $entity;
Expand All @@ -31,7 +31,7 @@ public static function createNew($connector_id, $core, $entity, $action, $parame
$call->record = array(
'status' => CallInterface::STATUS_INIT,
'connector_id' => $call->getConnectorID(),
'request' => json_encode($call->request),
'request' => json_encode($call->request),
'metadata' => '{}',
'request_hash' => $call->getHash(),
'create_date' => date('YmdHis'),
Expand All @@ -50,7 +50,7 @@ public static function createNew($connector_id, $core, $entity, $action, $parame
public static function createWithRecord($connector_id, $core, $record) {
$call = new Call($core, $connector_id, $record->cid);
$call->record = json_decode(json_encode($record), TRUE);
$call->request = json_decode($call->record['request'], TRUE);
$call->request = json_decode($call->record['request'], TRUE);
$call->reply = json_decode($call->record['reply'], TRUE);
return $call;
}
Expand Down Expand Up @@ -107,9 +107,18 @@ public function triggerCallback() {


public function setStatus($status, $error_message, $error_code = NULL) {
$this->data['status'] = $status;
$this->data['error_message'] = $error_message;
$this->data['error_code'] = $error_code;
$error = array(
'is_error' => '1',
'error_message' => $error_message,
'error_code' => $error_code);

// update the DB
$update = array(
'cid' => $this->id,
'status' => $status,
'reply_date' => date('YmdHis'),
'reply' => json_encode($error));
drupal_write_record('cmrf_core_call', $update, array('cid'));
}
}

8 changes: 3 additions & 5 deletions cmrf_core.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ description = CMRF CiviCRM REST Connection
core = 7.x

; Information added by Drupal.org packaging script on 2014-10-18
version = "7.x-1.x-dev"
core = "7.x"
project = "drupal_module_boilerplate"
datestamp = "1413658731"

project = "cmrf_core"
version = "7.x-0.1"
datestamp = "1492613168"

0 comments on commit 23762eb

Please sign in to comment.