Improve error messages
This improves error messages throughout. It might sometimes be too verbose, but that's better than being opaque (#74). Also upgrades Deno's patch version. Fixes #74
This commit is contained in:
@@ -37,6 +37,11 @@ export default function Articles({ initialArticles }: ArticlesProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to refresh articles. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as RefreshResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
@@ -87,6 +92,11 @@ export default function Articles({ initialArticles }: ArticlesProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to mark article as read. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as ReadResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
@@ -114,6 +124,11 @@ export default function Articles({ initialArticles }: ArticlesProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to mark all articles as read. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as ReadResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
|
||||
@@ -84,6 +84,11 @@ export default function Feeds({ initialFeeds }: FeedsProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to add feed. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as AddResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
@@ -116,6 +121,11 @@ export default function Feeds({ initialFeeds }: FeedsProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to delete feed. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as DeleteResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
@@ -168,6 +178,11 @@ export default function Feeds({ initialFeeds }: FeedsProps) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to import feeds. ${response.statusText} ${await response.text()}`);
|
||||
}
|
||||
|
||||
const result = await response.json() as ImportResponseBody;
|
||||
|
||||
if (!result.success) {
|
||||
|
||||
Reference in New Issue
Block a user