Skip to content

Errors

Typed failures for @jayoncode/storage. Prefer instanceof / code over matching message.

Previous: Core · Next: Maintenance

Hierarchy

ClasscodeTypical cause
ConfigurationErrorconfiguration_errorBad namespace/key, unknown policy, clear without keys
SerializationErrorserialization_errorJSON failure, non-envelope payload
MigrationErrormigration_errorVersion mismatch without hook / bad migrate return
QuotaExceededErrorquota_exceededBrowser/Lab hard quota, or soft guard (/quota) over max
AdapterErroradapter_errorUnavailable Storage or other I/O

Optional cause and details may be present.

Soft null (not errors)

  • Missing key
  • Expired key (lazy-deleted on peek/get/has)
  • migrate returned null (key removed)

Guidance

ts
try {
  storage.set("prefs", value, { policy: "preferences" });
} catch (error) {
  if (error instanceof QuotaExceededError || isQuotaExceededError(error)) {
    // free space / drop cache keys
  } else if (error instanceof ConfigurationError) {
    throw error; // fix the call site
  } else {
    throw error;
  }
}

has / peek do not run migrations (they will not throw MigrationError for version mismatch). Call get to migrate.

Playground

Enable Simulate quota on set for hard adapter failures, or Soft max bytes for enableQuotaGuard.

Next

Maintenance · FAQ · Best practices

An ecosystem of independent, headless TypeScript libraries engineered for modern web development. Every package includes interactive playgrounds and documentation that evolves alongside the code.