---
title: "isConvexError"
description: "Reference for the type guard that recognizes ConvexError values and matches their error code."
canonical_url: "https://nuxt-convex.onmax.me/api-reference/is-convex-error"
---
# isConvexError

> Reference for the type guard that recognizes ConvexError values and matches their error code.

`isConvexError` tells a `ConvexError` thrown by your function apart from other failures, and optionally matches its code.

## Import

```ts [Nuxt]
// Auto-imported, or explicitly:
import { isConvexError } from '#convex'
```

```ts [Vue]
import { isConvexError } from 'vue-convex'
```

## Signature

```ts
function isConvexError(error: unknown, code?: string): error is ConvexError<Value>
```

## Behavior

- Returns `true` for a `ConvexError`, including one rebuilt from the SSR payload during hydration or from another copy of the `convex` package.
- With `code`, also requires `error.data === code`, or `error.data.code === code` when `data` is an object.

```ts
// convex/tasks.ts
throw new ConvexError({ code: 'NOT_FOUND', id })

// in a component
if (isConvexError(error.value, 'NOT_FOUND'))
  showNotFound(error.value.data)
```

## Related pages

- [Error Handling](https://nuxt-convex.onmax.me/nuxt-module/error-handling)
- [useConvexQuery](https://nuxt-convex.onmax.me/api-reference/use-convex-query)


## Sitemap

See the full [sitemap](https://nuxt-convex.onmax.me/sitemap.md) for all pages.
