From 14fd7b57a25f84ddad448280a74ebfb6af647e9a Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 26 Aug 2024 20:13:16 +0300 Subject: [PATCH] Refine error handling text (#816) * Refine error handling text * Apply suggestions from code review Co-authored-by: Addison Phillips * Update fallback text * Turn bullet point list into paragraphs * Be more mighty Co-authored-by: Addison Phillips --------- Co-authored-by: Addison Phillips --- spec/errors.md | 19 ++++++++++++++++--- spec/formatting.md | 5 ++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/spec/errors.md b/spec/errors.md index 7a6375ee..a2ddd669 100644 --- a/spec/errors.md +++ b/spec/errors.md @@ -24,9 +24,22 @@ or _Message Function Errors_ in _expressions_ that are not otherwise used by the such as _placeholders_ in unselected _patterns_ or _declarations_ that are never referenced during _formatting_. -In all cases, when encountering a runtime error, -a message formatter MUST provide some representation of the message. -An informative error or errors MUST also be separately provided. +When formatting a _message_ with one or more errors, +an implementation MUST provide a mechanism to discover and identify +at least one of the errors. +The exact form of error signaling is implementation defined. +Some examples include throwing an exception, +returning an error code, +or providing a function or method for enumerating any errors. + +For all _messages_ without _Syntax Errors_ or _Data Model Errors_, +an implementation MUST enable a user to get a formatted result. +The formatted result might include _fallback values_ +such as when a _placeholder_'s _expression_ produced an error +during formatting. + +The two above requirements MAY be fulfilled by a single formatting method, +or separately by more than one such method. When a message contains more than one error, or contains some error which leads to further errors, diff --git a/spec/formatting.md b/spec/formatting.md index 0acaa789..5e71d24a 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -741,9 +741,8 @@ each _text_ and _placeholder_ part of the selected _pattern_ is resolved and for Resolved values cannot always be formatted by a given implementation. When such an error occurs during _formatting_, -an implementation SHOULD emit an appropriate _Message Function Error_ and produce a -_fallback value_ for the _placeholder_ that produced the error. -A formatting function MAY substitute a value to use instead of a _fallback value_. +an implementation MUST emit an appropriate _Message Function Error_ and use a +_fallback value_ for the _placeholder_ with the error. Implementations MAY represent the result of _formatting_ using the most appropriate data type or structure. Some examples of these include: