demo · v138

Error Catching Guide

Chrome 138 turns QuotaExceededError from a plain DOMException with a magic name string into a proper derived interface. There are now several ways to catch it — some correct, some fragile. Click each pattern to see what it catches and whether it works reliably across browsers.

Checking QuotaExceededError interface support…

Catching patterns — click to evaluate

name check works everywhere
catch (e) {
  if (e.name === 'QuotaExceededError') …
}

The classic approach. Works in all browsers including pre-138. Still valid.
instanceof DOMException works everywhere
catch (e) {
  if (e instanceof DOMException) …
}

Too broad — catches ALL DOMExceptions. Must combine with name check in older browsers.
instanceof QuotaExceededError Chrome 138+
catch (e) {
  if (e instanceof QuotaExceededError) …
}

The new, clean, specific check. Has its own class now. Falls back gracefully when class isn't defined.
access quota fields Chrome 138+
e.quota // bytes available
e.requested // bytes requested

New fields only exist on the new interface. Access them safely with optional chaining.
combined safe pattern recommended
Checks instanceof QuotaExceededError first (Chrome 138+), then falls back to e.name check. Handles all browsers correctly.
Select a pattern above
Click a pattern card to see the code.
Result

instanceof chain for a simulated QuotaExceededError

// Chrome 138+: QuotaExceededError is a real class
try {
  await navigator.storage.persist();
  // trigger quota error...
} catch (e) {
  // Recommended cross-browser pattern:
  const isQuota = (typeof QuotaExceededError !== 'undefined' &&
                   e instanceof QuotaExceededError)
               || e.name === 'QuotaExceededError';

  if (isQuota) {
    // Chrome 138+: rich fields available
    const quota     = e.quota;      // bytes available (may be undefined pre-138)
    const requested = e.requested;  // bytes requested

    const msg = quota != null
      ? `Need ${requested - quota} more bytes`
      : 'Quota exceeded';

    showStorageDialog(msg);
  }
}

see also