File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable no-console, antfu/no-top-level-await */
2
2
import KeyvFile from "keyv-file" ;
3
3
import prompts from "prompts" ;
4
- import { VRChat } from "vrchat" ;
4
+ import { VRChat , VRChatError } from "vrchat" ;
5
5
6
6
const vrchat = new VRChat ( {
7
7
/**
@@ -32,7 +32,11 @@ const { data: user } = await vrchat
32
32
. getCurrentUser ( { throwOnError : true } )
33
33
// Since we've passed `throwOnError: true`, this will throw an error if the user is not logged in.
34
34
// We can catch that error and prompt the user for their credentials.
35
- . catch ( async ( ) => {
35
+ . catch ( async ( reason ) => {
36
+ // Rethrow the error if it's not a 401 Unauthorized error.
37
+ if ( ! ( reason instanceof VRChatError ) || reason . statusCode !== 401 )
38
+ throw reason ;
39
+
36
40
/**
37
41
* Ask the user for their VRChat username and password.
38
42
* You can also use environment variables, or any other method to get the credentials.
You can’t perform that action at this time.
0 commit comments