diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e01db..134a594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Use `/feeds/users/{username}` path for user's Atom feed. +- Read error messages from `error_description` field instead of `message`. ## [1.14.0] - 2023-02-22 diff --git a/src/api/markers.ts b/src/api/markers.ts index 106ef2c..14e2e77 100644 --- a/src/api/markers.ts +++ b/src/api/markers.ts @@ -19,7 +19,7 @@ export async function getNotificationMarker( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data.notifications } @@ -36,7 +36,7 @@ export async function updateNotificationMarker( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data.notifications } diff --git a/src/api/nft.ts b/src/api/nft.ts index c316216..ff102f0 100644 --- a/src/api/nft.ts +++ b/src/api/nft.ts @@ -18,7 +18,7 @@ export async function makePermanent( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -35,7 +35,7 @@ export async function getMintingAuthorization( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -79,7 +79,7 @@ export async function onTokenMinted( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } diff --git a/src/api/notifications.ts b/src/api/notifications.ts index 0bc1b97..187e0dd 100644 --- a/src/api/notifications.ts +++ b/src/api/notifications.ts @@ -25,7 +25,7 @@ export async function getNotifications( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } diff --git a/src/api/posts.ts b/src/api/posts.ts index 1b49c0f..699bf2a 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -21,7 +21,7 @@ export async function uploadAttachment( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -157,7 +157,7 @@ export async function getPostThread( const response = await http(url, { authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -231,7 +231,7 @@ export async function createPost( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -244,7 +244,7 @@ export async function getPost( const response = await http(url, { authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -260,7 +260,7 @@ export async function deletePost( }) if (response.status !== 204) { const data = await response.json() - throw new Error(data.message) + throw new Error(data.error_description) } } @@ -272,7 +272,7 @@ export async function favourite( const response = await http(url, { method: "POST", authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -285,7 +285,7 @@ export async function unfavourite( const response = await http(url, { method: "POST", authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -298,7 +298,7 @@ export async function createRepost( const response = await http(url, { method: "POST", authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } if (data.reblog === null) { throw new Error("reblog property is null") @@ -314,7 +314,7 @@ export async function deleteRepost( const response = await http(url, { method: "POST", authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } diff --git a/src/api/relationships.ts b/src/api/relationships.ts index 83b0585..37b62a3 100644 --- a/src/api/relationships.ts +++ b/src/api/relationships.ts @@ -30,7 +30,7 @@ export async function follow( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -48,7 +48,7 @@ export async function getRelationship( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data[0] } @@ -64,7 +64,7 @@ export async function unfollow( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } diff --git a/src/api/search.ts b/src/api/search.ts index d93351f..8ed7b93 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -23,7 +23,7 @@ export async function getSearchResults( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -38,7 +38,7 @@ export async function searchProfilesByAcct( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -53,7 +53,7 @@ export async function searchProfilesByEthereumAddress( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } diff --git a/src/api/settings.ts b/src/api/settings.ts index 9c02334..9ac42ca 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -14,7 +14,7 @@ export async function changePassword( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -65,7 +65,7 @@ export async function importFollows( }) if (response.status !== 204) { const data = await response.json() - throw new Error(data.message) + throw new Error(data.error_description) } } @@ -82,7 +82,7 @@ export async function moveFollowers( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } diff --git a/src/api/subscriptions-common.ts b/src/api/subscriptions-common.ts index 7a8e15c..5fe4a50 100644 --- a/src/api/subscriptions-common.ts +++ b/src/api/subscriptions-common.ts @@ -45,7 +45,7 @@ export async function getSubscriptionOptions( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -63,7 +63,7 @@ export async function registerSubscriptionOption( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -89,7 +89,7 @@ export async function findSubscription( } else if (response.status === 404) { return null } else { - throw new Error(data.message) + throw new Error(data.error_description) } } diff --git a/src/api/subscriptions-ethereum.ts b/src/api/subscriptions-ethereum.ts index a5cde65..2d8c871 100644 --- a/src/api/subscriptions-ethereum.ts +++ b/src/api/subscriptions-ethereum.ts @@ -47,7 +47,7 @@ export async function getSubscriptionAuthorization( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } diff --git a/src/api/subscriptions-monero.ts b/src/api/subscriptions-monero.ts index a187887..5c17943 100644 --- a/src/api/subscriptions-monero.ts +++ b/src/api/subscriptions-monero.ts @@ -76,7 +76,7 @@ export async function createInvoice( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -91,7 +91,7 @@ export async function getInvoice( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } diff --git a/src/api/users.ts b/src/api/users.ts index e348654..8690431 100644 --- a/src/api/users.ts +++ b/src/api/users.ts @@ -147,7 +147,7 @@ export async function createUser(userData: UserCreateForm): Promise { }) const data = await response.json() if (response.status !== 201) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -175,7 +175,7 @@ export async function getAccessToken( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data.access_token } @@ -192,7 +192,7 @@ export async function revokeAccessToken( }) if (response.status !== 200) { const data = await response.json() - throw new Error(data.message) + throw new Error(data.error_description) } } @@ -214,7 +214,7 @@ export async function lookupProfile( const response = await http(url, { authToken, queryParams: { acct } }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -227,7 +227,7 @@ export async function getProfile( const response = await http(url, { authToken }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } return data } @@ -270,7 +270,7 @@ export async function updateProfile( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -313,7 +313,7 @@ export async function sendSignedActivity( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data } @@ -347,7 +347,7 @@ export async function createIdentityProof( }) const data = await response.json() if (response.status !== 200) { - throw new Error(data.message) + throw new Error(data.error_description) } else { return data }