add link for redirect in setup module
This commit is contained in:
parent
ec0fd31386
commit
831aee8fa2
2 changed files with 9 additions and 3 deletions
|
|
@ -67,7 +67,13 @@ $function = 'textgeneration';
|
|||
$generatedContent = $ai->generateContent($instructions, 'auto', $function);
|
||||
|
||||
if (is_array($generatedContent) && $generatedContent['error']) {
|
||||
print "Error : " . $generatedContent['message'];
|
||||
// client errors
|
||||
if ($generatedContent['code'] >= 400) {
|
||||
print "Error : " . $generatedContent['message'];
|
||||
print '<br><a href="'.DOL_MAIN_URL_ROOT.'/ai/admin/setup.php">'.$langs->trans('Check Config of Module').'</a>';
|
||||
} else {
|
||||
print "Error : " . $generatedContent['message'];
|
||||
}
|
||||
} else {
|
||||
print $generatedContent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class Ai
|
|||
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
throw new Exception('cURL error: ' . curl_error($ch));
|
||||
throw new Exception('Wrong configuration !' . curl_error($ch));
|
||||
}
|
||||
|
||||
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
|
@ -146,7 +146,7 @@ class Ai
|
|||
|
||||
return $generatedEmailContent;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => true, 'message' => $e->getMessage());
|
||||
return array('error' => true, 'message' => $e->getMessage(), 'code' => $statusCode);
|
||||
} finally {
|
||||
curl_close($ch);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue