| 107 | } |
| 108 | |
| 109 | set( |
| 110 | name: string, |
| 111 | value: string, |
| 112 | ): { isQuotaError: boolean; error: Error | null } { |
| 113 | let quotaError = false; |
| 114 | let error: Error | null = null; |
| 115 | |
| 116 | if (this.storage) { |
| 117 | const key = `${STORAGE_NAMESPACE}:${name}`; |
| 118 | if (value) { |
| 119 | try { |
| 120 | this.storage.setItem(key, value); |
| 121 | } catch (e) { |
| 122 | error = e instanceof Error ? e : new Error(`${e}`); |
| 123 | quotaError = isQuotaError(this.storage, e); |
| 124 | } |
| 125 | } else { |
| 126 | // Clean up by removing the item if there's no value to set |
| 127 | this.storage.removeItem(key); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return { isQuotaError: quotaError, error }; |
| 132 | } |
| 133 | |
| 134 | clear() { |
| 135 | if (this.storage) { |