try catch for plain text
This commit is contained in:
parent
02f15d573a
commit
abbe047bfd
2 changed files with 19 additions and 10 deletions
|
@ -118,7 +118,7 @@ export default abstract class Exporter {
|
||||||
limit = 40;
|
limit = 40;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
limit = Number.MAX_VALUE;
|
limit = 10**8;
|
||||||
}
|
}
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,25 @@ export default class PlainTextExporter extends Exporter {
|
||||||
|
|
||||||
protected _textForEvent = async (mxEv: MatrixEvent) => {
|
protected _textForEvent = async (mxEv: MatrixEvent) => {
|
||||||
const senderDisplayName = mxEv.sender && mxEv.sender.name ? mxEv.sender.name : mxEv.getSender();
|
const senderDisplayName = mxEv.sender && mxEv.sender.name ? mxEv.sender.name : mxEv.getSender();
|
||||||
if (this.exportOptions.attachmentsIncluded && this.isAttachment(mxEv)) {
|
let mediaText = "";
|
||||||
const blob = await this.getMediaBlob(mxEv);
|
if (this.isAttachment(mxEv)) {
|
||||||
this.totalSize += blob.size;
|
if (this.exportOptions.attachmentsIncluded) {
|
||||||
const filePath = this.getFilePath(mxEv);
|
try {
|
||||||
this.addFile(filePath, blob);
|
const blob = await this.getMediaBlob(mxEv);
|
||||||
if (this.totalSize > this.exportOptions.maxSize - 1024 * 1024) {
|
this.totalSize += blob.size;
|
||||||
this.exportOptions.attachmentsIncluded = false;
|
const filePath = this.getFilePath(mxEv);
|
||||||
}
|
mediaText = " (" + _t("File Attached") + ")";
|
||||||
|
this.addFile(filePath, blob);
|
||||||
|
if (this.totalSize > this.exportOptions.maxSize - 1024 * 1024) {
|
||||||
|
this.exportOptions.attachmentsIncluded = false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
mediaText = " (" + _t("Error fetching file") + ")";
|
||||||
|
console.log("Error fetching file" + error);
|
||||||
|
}
|
||||||
|
} else mediaText = ` (${this.mediaOmitText})`;
|
||||||
}
|
}
|
||||||
if (this.isReply(mxEv)) return senderDisplayName + ": " + this.textForReplyEvent(mxEv);
|
if (this.isReply(mxEv)) return senderDisplayName + ": " + this.textForReplyEvent(mxEv) + mediaText;
|
||||||
else return textForEvent(mxEv);
|
else return textForEvent(mxEv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue