diff --git a/site/client/src/components/LinksPopup.svelte b/site/client/src/components/LinksPopup.svelte
index aced022cb..f71772ec0 100644
--- a/site/client/src/components/LinksPopup.svelte
+++ b/site/client/src/components/LinksPopup.svelte
@@ -6,7 +6,7 @@
import { LANGUAGE_CTX, LanguageContext } from '../data/languageContext';
import Button from './Button.svelte';
- import { save } from '../data/sessionController';
+ import { CustomError, save } from '../data/sessionController';
import CopyButton from './CopyButton.svelte';
export let node: HTMLElement;
@@ -104,9 +104,10 @@
- {:catch _err}
+ {:catch err}
{/await}
{:else}
@@ -209,6 +210,16 @@
margin-top: 16px;
}
+ .links-popup__error-icon {
+ display: inline-block;
+ width: 16px;
+ height: 16px;
+ margin-right: 4px;
+ vertical-align: -0.1em;
+ background: no-repeat 50% 50% url(../assets/errors.svg);
+ background-size: contain;
+ }
+
@keyframes rotate {
from {
transform: rotate(0);
diff --git a/site/client/src/data/sessionController.ts b/site/client/src/data/sessionController.ts
index ecf07fff0..ba4aac0c9 100644
--- a/site/client/src/data/sessionController.ts
+++ b/site/client/src/data/sessionController.ts
@@ -151,6 +151,12 @@ async function genLinks(uuid: string) {
};
}
+export class CustomError extends Error {
+ constructor(message?: string) {
+ super(message);
+ }
+}
+
export async function save() {
const curSession = get(session);
if (curSession.uuid && curSession.writeKey) {
@@ -172,7 +178,13 @@ export async function save() {
}).then(
res => {
if (!res.ok) {
- throw new Error('Not ok');
+ return res.json().then(json => {
+ if (json && json.error) {
+ throw new CustomError(json.error);
+ } else {
+ throw new Error('Not ok');
+ }
+ });
}
return res.json();
}
diff --git a/site/server/app.js b/site/server/app.js
index d735b3922..5cbc8254b 100644
--- a/site/server/app.js
+++ b/site/server/app.js
@@ -75,6 +75,10 @@ router.post('/api/share', async ctx => {
if (err instanceof DataViolationError) {
ctx.status = 400;
+ ctx.body = {
+ ok: 0,
+ error: err.message
+ };
} else {
ctx.status = 500;
}