撰写切实可行的错误消息
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了编写实用错误消息的最佳实践,这些消息可告知用户如何解决问题,以便用户完成目标。
当用户与 Google Chat 应用互动时,如果错误消息不可操作,用户体验会非常糟糕。例如,错误消息 An error occurred
就没什么用,因为该消息没有说明出了什么问题、用户如何解决问题或用户如何获得帮助。本页面介绍了如何构建错误消息,以便通过显示可操作和不可操作的示例来帮助用户。
错误消息结构
可操作的错误消息具有以下结构:
- 出了什么问题。说明聊天应用无法完成请求的原因有助于用户解决问题。说明发生错误的原因有助于建立信任。
- 用户如何朝着目标迈进。仅仅说明出了什么问题是不够的。告知用户如何解决此错误并完成目标。
- 如何获取帮助。如果用户仍然卡在这一步,请告知他们如何获取更多帮助。这可以是
/help
命令,也可以是指向 Chat 应用文档的链接。
在此示例中,用户输入的日期格式与 Chat 应用预期的格式不符。他们写的是 November 19, 2021
,但 Chat 应用需要的是 2021-11-19
。
以下是 Chat 应用返回的错误消息的可操作版本和不可操作版本:
可操作的错误
用户要求 Chat 应用安排与另一人的会议。聊天应用会返回一条有用的可操作错误消息:
I don't recognize the date format you entered. Write dates as `yyyy-mm-dd`; for example, `2000-01-31`. For help, type `/help`.
此错误消息之所以可采取措施,是因为:
- 说明了哪里出了问题。Chat 应用无法识别日期格式。
- 通过告知用户预期的日期格式来解释如何修正错误,并提供一个日期示例,帮助用户了解应如何输入日期。
- 通过
/help
斜杠命令提供更多帮助。如果用户仍然遇到问题,他们知道如何了解详情。
无法采取行动的错误
用户要求 Chat 应用安排与另一人的会议。聊天应用会返回一条无用且无法采取行动的错误消息:
Enter the correct date format.
此错误消息无法采取任何措施,原因如下:
- 未说明是否已安排会议。用户可能不愿重新安排会议,或者可能认为会议已安排妥当。
- 未告知用户如何设置日期格式。不应假设用户知道如何设置日期格式,而应说明系统需要
yyyy-mm-dd
日期格式。
- 不提供更多帮助。当用户遇到困难且不知道如何继续时,可能会停止向 Chat 应用发送消息。
试试看
现在您已经了解如何编写可操作的错误,那么在以下场景中,您能否找出哪些错误是可操作的:
当用户向 Chat 应用发送包含关键字 schedule
的消息时,该 Chat 应用会创建日历活动。如需创建日历活动,Chat 应用需要用户进行身份验证。如果用户未通过身份验证,Chat 应用会返回错误消息。
哪些错误消息可执行操作?
在安排会议之前,您必须输入 /signin
进行登录。如需了解详情,请键入 /help
。
此错误消息可采取措施,因为它包含以下内容:
- 哪些方面出了问题。Chat 应用需要进行身份验证。
- 如何继续。输入
/signin
进行身份验证。
- 如何获取帮助。如果用户想要了解更多信息,可以输入
/help
。
您必须进行身份验证。
此错误消息无法采取行动,因为它未说明如何进行身份验证。
登录。
此错误消息无法采取行动,因为它没有说明如何登录,并且暗示用户已退出账号,而不是明确说明,这会让用户感到困惑。
无法安排会议。
此错误消息无法采取行动,因为它没有告知用户会议无法安排的原因,也没有告知用户可以如何继续操作。未提供帮助。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eGoogle Chat app error messages should be actionable, guiding users on how to resolve issues and proceed.\u003c/p\u003e\n"],["\u003cp\u003eActionable error messages clearly explain the problem, provide steps for fixing it, and offer additional help resources.\u003c/p\u003e\n"],["\u003cp\u003eInactionable error messages are vague, lack guidance, and can lead to user frustration and abandonment.\u003c/p\u003e\n"],["\u003cp\u003eUse the actionable error message structure: state the problem, guide the user on fixing it, and offer further help (e.g., \u003ccode\u003e/help\u003c/code\u003e command).\u003c/p\u003e\n"],["\u003cp\u003eWhen writing error messages, assume users need clear instructions and avoid ambiguity.\u003c/p\u003e\n"]]],["Actionable error messages in Google Chat apps should specify what went wrong, how to fix it, and how to get further assistance. For example, an actionable message for an incorrect date format would state that the format is unrecognized, specify the required format (yyyy-mm-dd), and provide a /help command. In contrast, inactionable errors are vague, omit how to correct the issue, and offer no additional support. A sign-in error should also include clear instructions, and help commands.\n"],null,["# Write actionable error messages\n\nThis page describes best practices to write actionable error messages that tell\nthe user how to fix the issue so that they can complete their goal.\n\nWhen a user is interacting with a Google Chat app, encountering\nerror messages can be a frustrating experience when the error isn't actionable.\nFor example, the error message, `An error occurred`, isn't useful because the\nmessage doesn't explain what went wrong, how the user can fix the issue, or how\nthe user can get help. This page describes how to structure error messages so\nthat they're useful to users by showing actionable and inactionable examples.\n\nError message structure\n-----------------------\n\nAn actionable error message has the following structure:\n\n- **What went wrong.** Saying why the Chat app can't complete a request helps the user resolve the issue. Explaining why an error occurred builds trust.\n- **How the user can proceed toward their goal.** It's never enough to just say what went wrong. Tell users how they can move past the error and complete their goal.\n- **How to get help.** If the user is still stuck, tell them how they can get more help. This could be a `/help` command or a link to documentation for your Chat app.\n\nExample error message: incorrect date format\n--------------------------------------------\n\nIn this example, the user entered a date in a format that\nthe Chat app didn't expect. They wrote\n`November 19, 2021`, but the Chat app expects\n`2021-11-19`.\n\nHere's an actionable and an inactionable version of the error message that the\nChat app responds with:\n\n#### Actionable error\n\nA user asks the Chat app to schedule a meeting with\nanother person. The Chat app responds with a good,\nactionable error message:\n\n``I don't recognize the date format you entered. Write dates as `yyyy-mm-dd`; for example, `2000-01-31`. For help, type `/help`.``\n\nThis error message is actionable for the following reasons:\n\n- Says what went wrong. The Chat app doesn't recognize the date format.\n- Explains how to fix the error by telling the user the expected date format and gives an example date that helps people understand what to write.\n- Offers more help with a `/help` slash command. If users are still stuck, they know how to learn more.\n\n#### Inactionable error\n\nA user asks the Chat app to schedule a meeting with\nanother person. The Chat app responds with an\nunhelpful, inactionable error message:\n\n`Enter the correct date format.`\n\nThis error message is inactionable for the following reasons:\n\n- Doesn't say whether it scheduled the meeting. The user might be hesitant to reschedule the meeting, or they might assume that the meeting was scheduled.\n- Doesn't tell the user how to format the date. Instead of assuming that users know how to format the date, it should say that it's expecting the date format `yyyy-mm-dd`.\n- Doesn't offer more help. When users are stuck and don't know how to proceed, they might stop messaging the Chat app.\n\nTry it out\n----------\n\nNow that you know how to write actionable errors, can you identify in the\nfollowing scenario which of these errors is actionable:\n\nA Chat app creates calendar events when users message\nthe Chat app with the keyword `schedule`. To\ncreate a calendar event, the Chat app requires user\nauthentication. If a user hasn't been authenticated, then the\nChat app responds with an error message. \nWhich error message is actionable? \nBefore I can schedule the meeting, you must sign in by typing `/signin`. To learn more, type `/help`. \nThis error message is actionable because it says the following:\n\n- What went wrong. The Chat app requires authentication.\n- How to proceed. Type `/signin` to authenticate.\n- How to get help. If the user wants more information, they can type `/help`. \nYou must authenticate. \nThis error message is inactionable because it doesn't say how to authenticate. \nSign in. \nThis error message is inactionable because it doesn't say how to sign in, and it implies that the user is signed out instead of clearly saying so, which is confusing. \nCan't schedule meeting. \nThis error message is inactionable because it doesn't tell the user why the meeting can't be scheduled or how the user can proceed. No help is provided."]]