From 4c7479a8a9a1db371b84aee5c770cc509fc4b55c Mon Sep 17 00:00:00 2001 From: Maxime Cannoodt Date: Wed, 29 Jun 2022 22:24:59 +0200 Subject: [PATCH] add error notices to plugin --- plugin/main.ts | 24 +++++++++++++++++++++--- plugin/src/NoteSharingService.ts | 4 +++- server/prisma/dev.db | Bin 815104 -> 815104 bytes 3 files changed, 24 insertions(+), 4 deletions(-) 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 1304bbba527b518da12cd00ae31b0178415b68a1..0fc7f042d045bf1da1c84d38fd483a79b657981f 100644 GIT binary patch delta 5188 zcmZ{nISlmZS;u#?*)JP*KYc=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