A simple Bluesky bot to make sense of the noise, with responses powered by Gemini, similar to Grok.

fix: send error messages before throwing error

+6 -4
+3 -2
src/handlers/messages.ts
··· 115 : env.AUTHORIZED_USERS.includes(message.senderDid as any); 116 117 if (!authorized) { 118 - conversation.sendMessage({ 119 text: c.UNAUTHORIZED_MESSAGE, 120 }); 121 ··· 157 parsedConversation.messages, 158 ); 159 if (!inference) { 160 - throw new Error("Failed to generate text. Returned undefined."); 161 } 162 163 const responseText = inference.text;
··· 115 : env.AUTHORIZED_USERS.includes(message.senderDid as any); 116 117 if (!authorized) { 118 + await conversation.sendMessage({ 119 text: c.UNAUTHORIZED_MESSAGE, 120 }); 121 ··· 157 parsedConversation.messages, 158 ); 159 if (!inference) { 160 + logger.error("Failed to generate text. Returned undefined."); 161 + return; 162 } 163 164 const responseText = inference.text;
+3 -2
src/utils/conversation.ts
··· 31 32 const postUri = await parseMessagePostUri(initialMessage); 33 if (!postUri) { 34 - convo.sendMessage({ 35 text: 36 "Please send a post for me to make sense of the noise for you.", 37 }); 38 throw new Error("No post reference in initial message."); 39 } 40 ··· 136 }), 137 }; 138 } catch (e) { 139 - convo.sendMessage({ 140 text: ERROR_MESSAGE, 141 }); 142
··· 31 32 const postUri = await parseMessagePostUri(initialMessage); 33 if (!postUri) { 34 + await convo.sendMessage({ 35 text: 36 "Please send a post for me to make sense of the noise for you.", 37 }); 38 + 39 throw new Error("No post reference in initial message."); 40 } 41 ··· 137 }), 138 }; 139 } catch (e) { 140 + await convo.sendMessage({ 141 text: ERROR_MESSAGE, 142 }); 143