# WrapDatabaseError

`function` in `plugins` · v0.6.1

<https://docs.seedcord.org/packages/plugins/0.6.1/functions/wrap-database-error>

Catches and wraps database operation errors.

Wraps non-CustomError exceptions in DatabaseError instances with UUID tracking. Should be applied to database service methods.

```ts
WrapDatabaseError<TypeReturn>(
    errorMessage: string
): (
    _target: unknown,
    _propertyKey: string,
    descriptor: TypedPropertyDescriptor<
        (...args: any[]) => Promise<TypeReturn>
    >
) => void
```

Catches and wraps database operation errors.

Wraps non-CustomError exceptions in DatabaseError instances with UUID tracking. Should be applied to database service methods.

Parameters.

- `errorMessage` `string` — Message to include when wrapping errors

Returns `(_target: unknown, _propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<TypeReturn>>) => void`.
