Skip to content

Commit 893e836

Browse files
committed
Fix #111 improve bs replyTo err log
1 parent 1e67472 commit 893e836

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/plugins/BioClip.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export default class BioClip {
8282
);
8383
}
8484
} catch (err) {
85-
console.log(err.stack);// print stack
85+
console.log(err);// print err
86+
console.log(err?.stack);// print stack
8687
console.trace();// print stack
8788
return pluginsCommonService.rejectWithIdentifyError(pluginName, step, candidate, err, context);
8889
}

src/services/PluginsCommonService.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ export default class PluginsCommonService {
116116
rejectWithIdentifyError(pluginName, step, candidate, err, context) {
117117
let {status, message, mustBeReported} = err;
118118
mustBeReported = isSet(mustBeReported) ? mustBeReported : true;
119-
let plantnetTxtError = `[${step}] Impossible d'identifier l'image avec ${pluginName}`;
120-
let plantnetHtmlError = plantnetTxtError;
119+
let pluginTxtError = `[${step}] Impossible d'identifier l'image avec ${pluginName}`;
120+
let pluginHtmlError = pluginTxtError;
121121
if (isSet(candidate)) {
122-
plantnetTxtError = `[${step}] Impossible d'identifier l'image de ${postLinkOf(candidate)} avec ${pluginName}`;
123-
plantnetHtmlError = `<b>Post</b>: <div class="bg-warning">${postHtmlOf(candidate)}</div>` +
122+
pluginTxtError = `[${step}] Impossible d'identifier l'image de ${postLinkOf(candidate)} avec ${pluginName}`;
123+
pluginHtmlError = `<b>Post</b>: <div class="bg-warning">${postHtmlOf(candidate)}</div>` +
124124
`<b>Erreur [${step}]</b>: impossible d'identifier l'image avec ${pluginName}`;
125125
}
126-
this.logger.error(`${plantnetTxtError} : ${message}`, context);
127-
return Promise.reject(pluginReject(plantnetTxtError, plantnetHtmlError,
126+
this.logger.error(`${pluginTxtError} : ${message}`, context);
127+
return Promise.reject(pluginReject(pluginTxtError, pluginHtmlError,
128128
isSet(status) ? status : 500,
129129
`${pluginName} unexpected error`, mustBeReported));
130130
}
@@ -204,7 +204,8 @@ export default class PluginsCommonService {
204204
));
205205
})
206206
.catch(err => {
207-
console.log(err.stack);// print stack
207+
console.log(err);// print err
208+
console.log(err?.stack);// print stack
208209
console.trace();// print stack
209210
plugin.logError("replyTo", err, {...context, doSimulate, replyTo, replyMessage});
210211
reject(new Error("impossible de répondre au post"));

src/servicesExternal/BlueSkyService.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,16 @@ export default class BlueSkyService {
226226
logger.info(`SIMULATE REPLY TO ${postLinkOf(post)} : ${text}${embedDesc}`);
227227
return {"uri": "simulated_reply_uri", "cid": "simulated_reply_cid"};
228228
}
229-
logger.debug("POST SENT:\n" + JSON.stringify(replyPost, null, 2));
230-
const postReplyResponse = await this.agent.post(replyPost)
231-
logger.info(`replyTo response : ${JSON.stringify(postReplyResponse)}`);
232-
logger.info(`replyTo ${postLinkOf(post)} : ${text}`);
233-
return postReplyResponse;
229+
try {
230+
logger.debug("POST SENT:\n" + JSON.stringify(replyPost, null, 2));
231+
const postReplyResponse = await this.agent.post(replyPost)
232+
logger.info(`replyTo response : ${JSON.stringify(postReplyResponse)}`);
233+
logger.info(`replyTo ${postLinkOf(post)} : ${text}`);
234+
return postReplyResponse;
235+
} catch (postException) {
236+
logger.error(`agent.post error ${postException.message}`);
237+
throw new InternalServerErrorException(`Bluesky replyTo was failed`);
238+
}
234239
}
235240

236241
prepareImageUrlAsBlueskyEmbed(imageUri, imageAltText) {

0 commit comments

Comments
 (0)