The alchemyAPI can return exceptions.

"lorem ispum" text will throw a new exception "Error making API call: unsupported-text-language" doing Drupal crash, specially bad with auto-tagging :(.

I didn't check all the code but here an example for function alchemy_get_elements

    // Extract topic keywords from a text string.
    try {
      switch ($type) {
        case 'entities':
          $resultstr = $alchemyObj->TextGetRankedNamedEntities($text);
          break;
        case 'categories':
          $resultstr = $alchemyObj->TextGetCategory($text);
          break;
        case 'concepts':
          $resultstr = $alchemyObj->TextGetRankedConcepts($text);
          break;
        case 'keywords':
          $resultstr = $alchemyObj->TextGetRankedKeywords($text);
          break;
      }
    } catch (Exception $exc) {
      dpm($exc->getMessage());
      return;
    }

Comments

gagarine’s picture

Oups .... of course I should not use dpm but a drupal_set_message

    // Extract topic keywords from a text string.
    try {
      switch ($type) {
        case 'entities':
          $resultstr = $alchemyObj->TextGetRankedNamedEntities($text);
          break;
        case 'categories':
          $resultstr = $alchemyObj->TextGetCategory($text);
          break;
        case 'concepts':
          $resultstr = $alchemyObj->TextGetRankedConcepts($text);
          break;
        case 'keywords':
          $resultstr = $alchemyObj->TextGetRankedKeywords($text);
          break;
      }
    } catch (Exception $exc) {
      drupal_set_message($exc->getMessage(),'warning');
      return;
    }
BoogieBug’s picture

I found the problem indirectly from the linkintel module which come from the same root cause - when entering an empty QuickSEO analyzer keyword it will generate a blank white page with the following error message in the log file.

PHP Fatal error:  Uncaught exception 'Exception' with message 'Enter some text to analyze.' in /opt/drupal6/sites/all/modules/alchemy/AlchemyAPI/module/AlchemyAPI.php:488, referer: http:/ ...

The code in #2 resolve this problem.

TomDude48’s picture

Status: Active » Fixed

Thanks gagarine for the code, I have it added.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.