11from vrcpy ._hardtyping import *
22
3- from vrcpy .errors import IntegretyError
3+ from vrcpy .errors import IntegretyError , GeneralError
44from vrcpy import types
55
66import asyncio
@@ -188,6 +188,11 @@ def __init__(self, client, obj=None):
188188 "isFriend"
189189 ]
190190
191+ self .types .update ({
192+ "location" : Location ,
193+ "instanceId" : Location
194+ })
195+
191196 if not obj == None :
192197 self ._assign (obj )
193198 if not hasattr (self , "bio" ):
@@ -203,11 +208,6 @@ def __init__(self, client, obj=None):
203208 "allowAvatarCopying"
204209 ]
205210
206- self .types .update ({
207- "location" : Location ,
208- "instanceId" : Location
209- })
210-
211211 if not obj == None :
212212 self ._assign (obj )
213213
@@ -492,12 +492,20 @@ def __init__(self, client, location):
492492 if ":" in location :
493493 self .worldId , location = location .split (":" )
494494
495- if "~" in location :
496- self .name , t , nonce = location .split ("~" )
497- self .type , self .userId = t [:- 1 ].split ("(" )
498- self .nonce = nonce .split ("(" )[1 ][:- 1 ]
499- else :
500- self .name = location
495+ originalLocation = location
496+
497+ try :
498+ if "~" in location :
499+ if location .count ("~" ) == 2 :
500+ self .name , t , nonce = location .split ("~" )
501+ self .type , self .userId = t [:- 1 ].split ("(" )
502+ self .nonce = nonce .split ("(" )[1 ][:- 1 ]
503+ elif location .count ("~" ) == 1 :
504+ self .name , self .type = location .split ("~" ) # Needs testing, https://github.com/vrchatapi/VRChatPython/issues/17
505+ else :
506+ self .name = location
507+ except Exception as e : # https://github.com/vrchatapi/VRChatPython/issues/17
508+ raise GeneralError ("Exception occured while trying to parse location string ({})! Please open an issue on github! {}" .format (originalLocation , e ))
501509
502510
503511class Instance (BaseObject ):
0 commit comments