add error notices to plugin
This commit is contained in:
parent
91f6205b90
commit
4c7479a8a9
@ -1,4 +1,11 @@
|
|||||||
import { MarkdownView, Menu, Plugin, TAbstractFile, TFile } from "obsidian";
|
import {
|
||||||
|
MarkdownView,
|
||||||
|
Menu,
|
||||||
|
Notice,
|
||||||
|
Plugin,
|
||||||
|
TAbstractFile,
|
||||||
|
TFile,
|
||||||
|
} from "obsidian";
|
||||||
import { NoteSharingService } from "src/NoteSharingService";
|
import { NoteSharingService } from "src/NoteSharingService";
|
||||||
import { DEFAULT_SETTINGS } from "src/obsidian/PluginSettings";
|
import { DEFAULT_SETTINGS } from "src/obsidian/PluginSettings";
|
||||||
import SettingsTab from "src/obsidian/SettingsTab";
|
import SettingsTab from "src/obsidian/SettingsTab";
|
||||||
@ -76,7 +83,18 @@ export default class NoteSharingPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async shareNote(mdText: string) {
|
async shareNote(mdText: string) {
|
||||||
const res = await this.noteSharingService.shareNote(mdText);
|
this.noteSharingService
|
||||||
new SharedNoteSuccessModal(this, res.view_url, res.expire_time).open();
|
.shareNote(mdText)
|
||||||
|
.then((res) => {
|
||||||
|
new SharedNoteSuccessModal(
|
||||||
|
this,
|
||||||
|
res.view_url,
|
||||||
|
res.expire_time
|
||||||
|
).open();
|
||||||
|
})
|
||||||
|
.catch((err: Error) => {
|
||||||
|
console.error(err);
|
||||||
|
new Notice(err.message, 7500);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,9 @@ export class NoteSharingService {
|
|||||||
returnValue.expire_time = moment(returnValue.expire_time);
|
returnValue.expire_time = moment(returnValue.expire_time);
|
||||||
return <Response>returnValue;
|
return <Response>returnValue;
|
||||||
}
|
}
|
||||||
throw Error("Did not get expected response from server on note POST.");
|
throw Error(
|
||||||
|
`Error uploading encrypted note (${res.status}): ${res.text}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sanitizeNote(mdText: string): string {
|
private sanitizeNote(mdText: string): string {
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user