קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
ה-API של Classroom מחזיר פרטי שגיאה שיכולים לעזור למפתחים לנפות באגים ולספק מידע שימושי למשתמשי הקצה. במדריך הזה מוסבר איך לנתח את פרטי השגיאה שמוחזרים מה-API.
ממשק ה-API של Classroom מחזיר שתי רמות של מידע על שגיאות:
קוד שגיאת HTTP בכותרת.
אובייקט בגוף התשובה עם פרטים נוספים.
המבנה של הודעת השגיאה
השגיאות שמוחזרות בגוף התשובה כוללות את השדות הבאים:
code: קוד השגיאה המספרי של HTTP. לדוגמה, 403.
message: פרטים נוספים על השגיאה. אם יש הודעה על שגיאה, היא מתחילה ב-@ ובסוג שגיאה ספציפי. לדוגמה: @ClassroomApiDisabled.
status: סטטוס הבקשה של ה-HTTP. לדוגמה, PERMISSION_DENIED או NOT_FOUND.
{"error":{"code":403,"message":"@ClassroomApiDisabled The user is not permitted to access the Classroom API.","status":"PERMISSION_DENIED"}}
תוכלו להשתמש בגוף התגובה כדי לנפות באגים ולזהות את הגורם לשגיאה, וגם לספק מידע שימושי למשתמשים. מומלץ לכלול רווח בסוף כשבודקים הודעת שגיאה ספציפית, כדי למנוע התאמה לערכים אחרים שמתחילים באותה מחרוזת. בדוגמה לשגיאה שצוינה, אפשר לבדוק אם שדה ההודעה מתחיל ב-"@ClassroomApiDisabled " כדי להציג למשתמשים את המידע המתאים.
בדף שגיאות נפוצות מפורט מידע על חלק מהשגיאות שיכולות להופיע ב-Classroom API.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-01-30 (שעון UTC)."],[[["The Classroom API provides error information via HTTP error codes in the header and detailed error objects in the response body."],["Error objects in the response body contain a numerical `code`, a detailed `message` potentially including a specific error type prepended with `@`, and an HTTP request `status`."],["Developers can use the error `message` field, particularly by checking for specific prefixes like `@ClassroomApiDisabled `, to debug issues and inform users."],["The error message structure provided by the API allows for the extraction of the HTTP code, the reason behind the error and its status."],["Refer to the Common Errors page to see a detailed list of possible error messages and the actions that can be taken in response to them."]]],[]]