@google/generative-ai
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -586,2 +586,6 @@ 'use strict'; | ||
/** | ||
* Do not log a message for this error. | ||
*/ | ||
const SILENT_ERROR = "SILENT_ERROR"; | ||
/** | ||
* ChatSession class that enables sending chat messages and stores | ||
@@ -673,2 +677,7 @@ * history of sent and received messages so far. | ||
.then(() => streamPromise) | ||
// This must be handled to avoid unhandled rejection, but jump | ||
// to the final catch block with a label to not log this error. | ||
.catch((_ignored) => { | ||
throw new Error(SILENT_ERROR); | ||
}) | ||
.then((streamResult) => streamResult.response) | ||
@@ -691,2 +700,12 @@ .then((response) => { | ||
} | ||
}) | ||
.catch((e) => { | ||
// Errors in streamPromise are already catchable by the user as | ||
// streamPromise is returned. | ||
// Avoid duplicating the error message in logs. | ||
if (e.message !== SILENT_ERROR) { | ||
// Users do not have access to _sendPromise to catch errors | ||
// downstream from streamPromise, so they should not throw. | ||
console.error(e); | ||
} | ||
}); | ||
@@ -693,0 +712,0 @@ return streamPromise; |
{ | ||
"name": "@google/generative-ai", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Google AI JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307611
3752