A decentralized music tracking and discovery platform built on AT Protocol 🎵

fix: improve error handling and logging in getProfile functions

+14 -12
+14 -12
apps/api/src/xrpc/app/rocksky/actor/getProfile.ts
··· 33 33 Effect.catchAll((err) => { 34 34 console.error(err); 35 35 return Effect.succeed({}); 36 - }), 36 + }) 37 37 ); 38 38 server.app.rocksky.actor.getProfile({ 39 39 auth: ctx.authVerifier, ··· 138 138 agent, 139 139 }: WithAgent): Effect.Effect<WithUser, Error> => { 140 140 return Effect.tryPromise({ 141 - try: async () => 142 - ctx.db 141 + try: async () => { 142 + console.log(">> did", did); 143 + return ctx.db 143 144 .select() 144 145 .from(tables.users) 145 146 .where(eq(tables.users.did, did)) ··· 150 151 params, 151 152 did, 152 153 agent, 153 - })), 154 + })); 155 + }, 154 156 catch: (error) => new Error(`Failed to retrieve current user: ${error}`), 155 157 }); 156 158 }; ··· 192 194 .from(tables.spotifyAccounts) 193 195 .leftJoin( 194 196 tables.users, 195 - eq(tables.spotifyAccounts.userId, tables.users.id), 197 + eq(tables.spotifyAccounts.userId, tables.users.id) 196 198 ) 197 199 .where(eq(tables.users.did, did)) 198 200 .execute() ··· 202 204 .from(tables.spotifyTokens) 203 205 .leftJoin( 204 206 tables.users, 205 - eq(tables.spotifyTokens.userId, tables.users.id), 207 + eq(tables.spotifyTokens.userId, tables.users.id) 206 208 ) 207 209 .where(eq(tables.users.did, did)) 208 210 .execute() ··· 212 214 .from(tables.googleDriveAccounts) 213 215 .leftJoin( 214 216 tables.users, 215 - eq(tables.googleDriveAccounts.userId, tables.users.id), 217 + eq(tables.googleDriveAccounts.userId, tables.users.id) 216 218 ) 217 219 .where(eq(tables.users.did, did)) 218 220 .execute() ··· 222 224 .from(tables.dropboxAccounts) 223 225 .leftJoin( 224 226 tables.users, 225 - eq(tables.dropboxAccounts.userId, tables.users.id), 227 + eq(tables.dropboxAccounts.userId, tables.users.id) 226 228 ) 227 229 .where(eq(tables.users.did, did)) 228 230 .execute() ··· 279 281 xata_createdat: profile.user.createdAt.toISOString(), 280 282 xata_updatedat: profile.user.updatedAt.toISOString(), 281 283 xata_version: 1, 282 - }), 283 - ), 284 + }) 285 + ) 284 286 ); 285 287 } else { 286 288 // Update existing user in background if handle or avatar or displayName changed ··· 313 315 xata_createdat: profile.user.createdAt.toISOString(), 314 316 xata_updatedat: new Date().toISOString(), 315 317 xata_version: (profile.user.xataVersion || 1) + 1, 316 - }), 317 - ), 318 + }) 319 + ) 318 320 ); 319 321 } 320 322 }