דיווח אוטומטי על שגיאות
אפשר לשלוח שגיאה מפונקציה לדיווח על שגיאות, כפי שמתואר בהמשך:
Node.js
Python
כדי לקבל דיווח מפורט יותר על שגיאות, אפשר להשתמש בלקוח לדיווח על שגיאות ספריות.
אפשר לראות את השגיאות שדווחו בקטע דיווח על שגיאות במסוף Google Cloud. אפשר גם לראות את השגיאות שדווחו פונקציה מסוימת כשבוחרים אותה מתוך רשימת הפונקציות במסוף Google Cloud.
חריגות שלא נתפסות על ידי הפונקציה יופיעו בדיווח על שגיאות. חשוב לזכור שסוגים מסוימים של חריגות שלא נתפסות (למשל, חריגות שמופקות באופן אסינכרוני) יגרמו להתחלה קרה בקריאה עתידית לפונקציה. כך זמן הריצה של הפונקציה יגדל.
דיווח ידני על שגיאות
מתבצעת שליחה אל Cloud Logging
הפונקציה error
מ-SDK של יומן של Cloud Functions תדווח על שגיאות גם ל-Cloud Logging וגם ל-Error Reporting. כדי לכלול הקשר נוסף מהשגיאה כנתונים מובְנים, מעבירים אובייקט שגיאה כארגומנטים השני:
} catch (err) {
// Attach an error object as the second argument
functions.logger.error(
"Unable to read quote from Firestore, sending default instead",
err
);
}