function project_output_error($prj, $e, $errors)
{
    $code = $e->getMessage();
    if ($code > 0) {
        $msg = isset($errors[$code]) ? $errors[$code] : '';
    } else {
        $code = 99;
        $msg = '未知异常';
    }
    $msg = project_convert_output($prj, $msg);
    $prj->fw->interface->out($code, $level = 'error', '', $msg);
}
$keywords_str = trim(io_get('keywords'));
$input = io_get('input');
$errmsgs = array(10 => '关键词为空哦亲', 50 => '接口调用出错啦');
try {
    if (empty($keywords_str)) {
        throw new CmsInterfaceException(10);
        _log('输入关键词为空', 'DEBUG');
    }
    $len = $len > 0 ? $len : 20;
    $prefix = project_convert_input($prj, $keywords_str);
    $controller = $prj->rs->data->ext['tags'];
    $db = $prj->CData->CDb->r;
    WF_Registry::set('db', $db);
    $keywords = explode(';', $keywords_str);
    $tags = $controller->suggestByKeywords($keywords);
    if (!is_array($tags)) {
        throw new CmsInterfaceException(50);
        _log("suggest 接口调用出错");
    }
    $data = project_convert_output($prj, $tags);
    $prj->fw->interface->out(0, 'success', '', $data);
} catch (CmsInterfaceException $e) {
    project_output_error($prj, $e, $msgs);
} catch (Exception $e) {
    $this->fw->interface->out($e->getCode(), $e->getMessage(), '', '');
}
function _log($msg, $level = 'ERROR')
{
    global $prj;
    $prj->CLog->w($level, $msg);
}