Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance ParseQuantityError to Include Suggested Values for Improved User Feedback #7543

Open
naronchen opened this issue Jan 13, 2025 · 0 comments

Comments

@naronchen
Copy link
Contributor

Feature Request: Enhance ParseQuantityError to Include Suggested Values

Problem Description
The current implementation of parseQuantityString in the Parser returns a ParseQuantityError with the following structure:

export interface ParseQuantityError {
  /** Union discriminator for [[QuantityParseResult]]. */
  ok: false;
  /** The specific error that occurred during parsing. */
  error: ParseError;
}

link
Current design only provides an error. It seemed a better design to suggest a possible value.

For example, with the default BaseFormat, an input like 1,..2 results in an error but also suggests a value of 1.2, that could guide users toward the correct format.

Proposed Enhancement
Include a "suggested value" in ParseQuantityError to make error handling more user-friendly. For instance:

Input: 1,..2
Current Output: Error without suggestion
Suggested Output: Error with a suggested value of 1.2

Use Case References
Rn this API is utilized in locations such as:
AccuDraw.ts#L1074
AccuDraw.ts#L1042

Currently, those methods only returns a value when parseResult.ok is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant