Last active
July 18, 2016 04:54
-
-
Save bkrall/6011872 to your computer and use it in GitHub Desktop.
Try/Catch in Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dbtng_example_entry_insert($entry) { | |
$return_value = NULL; | |
try { | |
$return_value = db_insert('dbtng_example') | |
->fields($entry) | |
->execute(); | |
} | |
catch (Exception $e) { | |
drupal_set_message(t('db_insert failed. Message = %message, query= %query', | |
array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error'); | |
} | |
return $return_value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment