소스 검색

Added some improved failure messages for terms

Stephen Ficklin 7 년 전
부모
커밋
6dfb74b98a

+ 10 - 0
tripal/api/tripal.entities.api.inc

@@ -1190,8 +1190,15 @@ function tripal_entity_label($entity) {
 }
 
 /**
+ * Retrieves details, including attached fields, for a given bundle.
  *
  * @param $bundle_name
+ *   The name of the bundle (e.g. bio_data_xx)
+ *
+ * @return
+ *   An array containing the name, label, controlled vocabulary details
+ *   and a list of fields attached to the bundle.  Returns FALSE
+ *   if the bundle does not exist.
  *
  * @ingroup tripal_entities_api
  */
@@ -1199,6 +1206,9 @@ function tripal_get_bundle_details($bundle_name) {
   global $user;
 
   $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+  if (!$bundle) {
+    return FALSE;
+  }
   $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
   $vocab = $term->vocab;
   $instances = field_info_instances('TripalEntity', $bundle->name);

+ 1 - 1
tripal/api/tripal.terms.api.inc

@@ -346,7 +346,7 @@ function tripal_add_term($details) {
 function tripal_get_term_details($vocabulary, $accession) {
 
   if (empty($vocabulary) OR empty($accession)) {
-    tripal_report_error('tripal_term', TRIPAL_ERROR, 'Unable to retrieve details for term due to missing vocabulary and/or accession.');
+    tripal_report_error('tripal_term', TRIPAL_ERROR, "Unable to retrieve details for term due to missing vocabulary and/or accession");
   }
 
   // TODO: we need some sort of administrative interface that lets the user

+ 6 - 3
tripal/includes/TripalFields/TripalField.inc

@@ -132,10 +132,13 @@ class TripalField {
       $this->term = tripal_get_term_details($vocabulary, $accession);
     }
     else {
-      tripal_report_error('tripal_field', TRIPAL_ERROR, 'Unable to instantiate Field :name due to missing vocabulary and/or accession.',
-        array(':name' => $class::$default_label));
+      $bundle = tripal_load_bundle_entity(array('name' => $instance['bundle']));
+      tripal_report_error('tripal_field', TRIPAL_ERROR,
+        'Unable to instantiate the field named, ":name", due to missing vocabulary and/or accession. The term provided was: ":term". The bundle is: ":bundle".',
+        array(':name' => $instance['field_name'],
+          ':term' => $vocabulary . ':' . $accession,
+          ':bundle' => $bundle->label));
     }
-
     if (!$instance) {
       tripal_set_message(t('Missing instance of field "%field"', array('%field' => $field['field_name'])), TRIPAL_ERROR);
     }

+ 5 - 3
tripal_chado/api/tripal_chado.custom_tables.api.inc

@@ -126,7 +126,9 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_if_exist
  *
  * @ingroup tripal_custom_tables_api
  */
-function chado_create_custom_table($table, $schema, $skip_if_exists = TRUE, $mview_id = NULL, $redirect = TRUE) {
+function chado_create_custom_table($table, $schema, $skip_if_exists = TRUE,
+    $mview_id = NULL, $redirect = TRUE) {
+
   global $databases;
   $created = 0;
   $recreated = 0;
@@ -204,10 +206,10 @@ function chado_create_custom_table($table, $schema, $skip_if_exists = TRUE, $mvi
   }
   catch (Exception $e) {
     $transaction->rollback();
+    $error = $e->getMessage();
     watchdog_exception('tripal_chado', $e);
-    $error = _drupal_decode_exception($e);
     drupal_set_message(t("Could not add custom table '%table_name': %message.",
-      array('%table_name' => $table, '%message' => $error['!message'])), 'error');
+        array('%table_name' => $table, '%message' => $error)), 'error');
     return FALSE;
   }