···8181 safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS')
8282 let { usersDid: didFromLookUp, pds: oldPds } = await handleAndPDSResolver(oldHandle)
8383 usersDid = didFromLookUp
8484- // usersDid = await handleResolver.resolve(oldHandle)
8585- // const didDoc = await docResolver.resolve(usersDid)
8686- // safeStatusUpdate(
8787- // statusUpdateHandler,
8888- // 'Resolving did document and finding your current PDS URL',
8989- // )
9090-9191- // let oldPds
9292- // try {
9393- // oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0]
9494- // .serviceEndpoint
9595- // } catch (error) {
9696- // console.error(error)
9797- // throw new Error('Could not find a PDS in the DID document.')
9898- // }
998410085 oldAgent = new AtpAgent({
10186 service: oldPds,
···143128 if (verificationCode) {
144129 createAccountRequest.verificationCode = verificationCode
145130 }
146146- const createNewAccount = await newAgent.com.atproto.server.createAccount(
147147- createAccountRequest,
148148- {
149149- headers: { authorization: `Bearer ${serviceJwt}` },
150150- encoding: 'application/json',
151151- },
152152- )
131131+ try {
132132+ const createNewAccount = await newAgent.com.atproto.server.createAccount(
133133+ createAccountRequest,
134134+ {
135135+ headers: { authorization: `Bearer ${serviceJwt}` },
136136+ encoding: 'application/json',
137137+ },
138138+ )
153139154154- if (createNewAccount.data.did !== usersDid.toString()) {
155155- throw new Error('Did not create the new account with the same did as the old account')
140140+ if (createNewAccount.data.did !== usersDid.toString()) {
141141+ throw new Error('Did not create the new account with the same did as the old account')
142142+ }
143143+ } catch (error) {
144144+ // Ideally should catch if the repo already exists, and if so silently log it and move along to the next step
145145+ if (error?.error === 'AlreadyExists') {
146146+ console.log('Repo already exists, logging in')
147147+ } else {
148148+ // Catches any other error and stops the migration process
149149+ throw error
150150+ }
156151 }
157152 }
158153 safeStatusUpdate(statusUpdateHandler, 'Logging in with the new account')