-
Notifications
You must be signed in to change notification settings - Fork 27
Update QuotaExceededError to a DOMException derived interface #468
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
Comments
cc @szewai |
Any use cases beyond that one API cited in the PR? |
I have the same question as @annevk. For the example, there is a token limit for each summarize request, so it's easy to define |
There are clear quotas and requested values for many (maybe all?) of the other cases. For some it doesn't necessarily make sense to expose for privacy reasons, and for others it might be theoretically a good idea but not necessarily a feature developers are clamoring for. Here's a quick skim of some cases I found (non-exhaustive):
In general, I think this pattern is a good one to have in the platform, for the reasons explained in https://github.com/webmachinelearning/writing-assistance-apis/blob/8e551408a57d79afc6b32c88597ef5728febd30b/README.md#too-large-inputs: instead of encouraging code like const usage = await measureUsage(input);
const quota = await getQuota();
if (usage < quota) {
await sendInput(input);
} else {
console.log(`${usage} > ${quota}, no good, reduce your input by ${(1 - usage/quota)*100)}%!!`);
} which requires 3 round trips to whatever the backing system is, we can encourage code like try {
await sendInput(input);
} catch (e) {
if (e.name !== "QuotaExceededError") { throw e; }
console.log(`${e.requested} > ${e.quota}, no good, reduce your input by ${(1 - e.requested/e.quota)*100)}%!!`);
} which requires 1 round trip to the backing system. |
WebKittens
@annevk
Title of the proposal
Update QuotaExceededError to a DOMException derived interface
URL to the spec
https://webidl.spec.whatwg.org/#idl-DOMException
URL to the spec's repository
https://github.com/whatwg/webidl
Issue Tracker URL
No response
Explainer URL
whatwg/webidl#1465
TAG Design Review URL
No response
Mozilla standards-positions issue URL
whatwg/html#10972
WebKit Bugzilla URL
No response
Radar URL
No response
Description
Currently, when the web platform wants to tell you when you've exceeded quota, it will use
DOMException
with the specificname
property set toQuotaExceededError
. However this does not allow carrying additional information.This proposes removing "QuotaExceededError" from the list of built-in
DOMException
names, and instead creates a class nameQuotaExceededError
from the list of built-inDOMException
and has the additional optional propertiesquota
andrequested
. We propose all instances of specs that throw "QuotaExceededError"DOMException
s get upgraded to instead throwQuotaExceededError
s. For now, such specs would leave thequota
andrequested
properties at their default value ofnull
, but they could eventually upgrade to include that data, if it's useful for their use case (and isn't, e.g., a privacy leak).The proposal PR outlines scenarios where this change may not be backward-incompatible. However, think they are rare coding patterns and anticipate low interoperability risk.
The text was updated successfully, but these errors were encountered: