aotrautils-srv 0.0.1352 → 0.0.1354

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- /*utils COMMONS library associated with aotra version : «1_29072022-2359 (12/04/2025-02:24:09)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (12/04/2025-02:39:05)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4898,7 +4898,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4898
4898
 
4899
4899
 
4900
4900
 
4901
- /*utils AI library associated with aotra version : «1_29072022-2359 (12/04/2025-02:24:09)»*/
4901
+ /*utils AI library associated with aotra version : «1_29072022-2359 (12/04/2025-02:39:05)»*/
4902
4902
  /*-----------------------------------------------------------------------------*/
4903
4903
 
4904
4904
 
@@ -5042,7 +5042,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
5042
5042
 
5043
5043
 
5044
5044
 
5045
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (12/04/2025-02:24:09)»*/
5045
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (12/04/2025-02:39:05)»*/
5046
5046
  /*-----------------------------------------------------------------------------*/
5047
5047
 
5048
5048
 
@@ -6880,16 +6880,34 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
6880
6880
  let responseData;
6881
6881
  try{
6882
6882
  responseData=parseJSON(responseDataStr);
6883
- }catch(error){
6883
+ }catch(parseError1){
6884
6884
  // CAUTION ! TODO : FIXME : We replace in response all single quotes with "`" (egrave) in order to avoid errors !
6885
6885
  // DEBUG
6886
6886
  responseDataStr=responseDataStr.replace(/'/gim,"`");
6887
- responseData=parseJSON(responseDataStr);
6887
+ try{
6888
+ responseData=parseJSON(responseDataStr);
6889
+ }catch(parseError2){
6890
+ // DBG
6891
+ lognow("WARN : Could not JSON parse the response data ! Must deal with the raw string:«"+responseDataStr+"»", parseError2);
6892
+ resolve( {response:response, responseDataStr:responseDataStr} );
6893
+ return;
6894
+ }
6888
6895
  }
6896
+
6897
+ // CAUTION : .request(...) => statusCode, .fetch(...) => status (performHTTPRequest(...) uses fetch(...))
6898
+ const status=reponse.status;
6899
+ if(status!=200){
6900
+ const error=nonull(reponse.statusMessage, "No error message for error code "+status);
6901
+ // TRACE
6902
+ console.error("Error:", error);
6903
+ reject(""+error, status);
6904
+ return;
6905
+ }
6906
+
6889
6907
  resolve( {responseData:responseData, response:response, responseDataStr:responseDataStr} );
6890
- }catch(error){
6908
+ }catch(parseError3){
6891
6909
  // DBG
6892
- lognow("WARN : Could not JSON parse the response data ! Must deal with the string:«"+responseDataStr+"»", error);
6910
+ lognow("WARN : Could not JSON parse the response data ! Must deal with the raw string:«"+responseDataStr+"»", parseError3);
6893
6911
  resolve( {response:response, responseDataStr:responseDataStr} );
6894
6912
  return;
6895
6913
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.1352",
3
+ "version": "0.0.1354",
4
4
  "main": "aotrautils-srv.build.js",
5
5
  "description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",