effect-app 4.0.0-beta.266 → 4.0.0-beta.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -157,6 +157,45 @@ export class OptimisticConcurrencyException extends TaggedErrorClass<OptimisticC
157
157
  }
158
158
  }
159
159
 
160
+ /**
161
+ * Raised by a store adapter when a database operation fails for an
162
+ * infrastructure reason (request timeout, throttle, 5xx, dropped socket, or any
163
+ * non-conflict error). Distinct from `OptimisticConcurrencyException`, which is
164
+ * an expected etag conflict.
165
+ *
166
+ * `transient` is set by the adapter for failures worth retrying (timeout /
167
+ * throttle / 5xx / network). `cause` is the underlying adapter error, carried
168
+ * through a `Defect` schema so it serializes (an `Error` encodes to
169
+ * `{ name, message, cause }`) instead of breaking JSON encoding of the channel.
170
+ *
171
+ * Treated by the api/client/FE machinery like an unexpected (500-class) error.
172
+ */
173
+ export class DatabaseError extends TaggedErrorClass<DatabaseError>()(
174
+ "DatabaseError",
175
+ {
176
+ message: S.String,
177
+ transient: S.Boolean,
178
+ cause: S.optional(S.Defect())
179
+ }
180
+ ) {
181
+ constructor(
182
+ args: { message?: string; transient?: boolean; cause?: unknown },
183
+ disableValidation?: boolean
184
+ ) {
185
+ super(
186
+ {
187
+ message: args.message ?? "Database operation failed",
188
+ transient: args.transient ?? false,
189
+ cause: args.cause
190
+ },
191
+ disableValidation as any
192
+ )
193
+ }
194
+ override toString() {
195
+ return `DatabaseError: ${this.message}`
196
+ }
197
+ }
198
+
160
199
  const MutationOnlyErrors = [
161
200
  InvalidStateError,
162
201
  OptimisticConcurrencyException
@@ -168,7 +207,8 @@ const GeneralErrors = [
168
207
  LoginError,
169
208
  UnauthorizedError,
170
209
  ValidationError,
171
- ServiceUnavailableError
210
+ ServiceUnavailableError,
211
+ DatabaseError
172
212
  ] as const
173
213
 
174
214
  export const SupportedErrors = S.Union([