diff --git a/plugin/main.ts b/plugin/main.ts index 4ebc72a..8d14162 100644 --- a/plugin/main.ts +++ b/plugin/main.ts @@ -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 { DEFAULT_SETTINGS } from "src/obsidian/PluginSettings"; import SettingsTab from "src/obsidian/SettingsTab"; @@ -76,7 +83,18 @@ export default class NoteSharingPlugin extends Plugin { } async shareNote(mdText: string) { - const res = await this.noteSharingService.shareNote(mdText); - new SharedNoteSuccessModal(this, res.view_url, res.expire_time).open(); + this.noteSharingService + .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); + }); } } diff --git a/plugin/src/NoteSharingService.ts b/plugin/src/NoteSharingService.ts index 46e4c75..e8b5a08 100644 --- a/plugin/src/NoteSharingService.ts +++ b/plugin/src/NoteSharingService.ts @@ -43,7 +43,9 @@ export class NoteSharingService { returnValue.expire_time = moment(returnValue.expire_time); return 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 { diff --git a/server/prisma/dev.db b/server/prisma/dev.db index 1304bbb..0fc7f04 100644 Binary files a/server/prisma/dev.db and b/server/prisma/dev.db differ