Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(nuxt,vue): Re-export error handling utilities from @clerk/shared #5155

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .changeset/strong-onions-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
"@clerk/nuxt": patch
"@clerk/vue": patch
---

Re-export error handling utilities from `@clerk/shared`

Example:

```vue
<script setup lang="ts">
import { useSignIn } from '@clerk/vue'
import { isClerkAPIResponseError } from '@clerk/vue/errors'

// ... form state refs and other setup ...
const { signIn } = useSignIn()

const handleSubmit = async () => {
try {
const signInAttempt = await signIn.value.create({
identifier: email.value,
password: password.value,
})
// ... handle successful sign in ...
} catch (err) {
// Type guard to safely handle Clerk API errors
if (isClerkAPIResponseError(err)) {
errors.value = err.errors // err.errors is properly typed as ClerkAPIError[]
}
}
}
</script>

<template>
<!-- Form template here -->
</template>
```
4 changes: 4 additions & 0 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"./composables": {
"types": "./dist/runtime/composables/index.d.ts",
"import": "./dist/runtime/composables/index.js"
},
"./errors": {
"types": "./dist/runtime/errors.d.ts",
"import": "./dist/runtime/errors.js"
}
},
"main": "./dist/module.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/nuxt/src/runtime/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
isClerkAPIResponseError,
isClerkRuntimeError,
isEmailLinkError,
isKnownError,
isMetamaskError,
EmailLinkErrorCodeStatus,
} from '@clerk/vue/errors';
1 change: 1 addition & 0 deletions packages/nuxt/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default defineConfig(() => {
'./src/runtime/composables/index.ts',
'./src/runtime/client/*.ts',
'./src/runtime/server/*.ts',
'./src/runtime/errors.ts',
],
format: ['esm'],
// Make sure to not bundle the imports
Expand Down
4 changes: 4 additions & 0 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"./internal": {
"types": "./dist/internal.d.ts",
"import": "./dist/internal.js"
},
"./errors": {
"types": "./dist/errors.d.ts",
"import": "./dist/errors.js"
}
},
"main": "./dist/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/vue/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
isClerkAPIResponseError,
isClerkRuntimeError,
isEmailLinkError,
isKnownError,
isMetamaskError,
EmailLinkErrorCodeStatus,
} from '@clerk/shared/error';
2 changes: 1 addition & 1 deletion packages/vue/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type EsbuildPlugin = NonNullable<Options['esbuildPlugins']>[number];
export default defineConfig(() => {
return {
clean: true,
entry: ['./src/index.ts', './src/internal.ts'],
entry: ['./src/index.ts', './src/internal.ts', './src/errors.ts'],
format: ['esm'],
bundle: true,
sourcemap: true,
Expand Down