Read error messages from "error_description" field instead of "message"
This commit is contained in:
parent
4d27411752
commit
177639614a
12 changed files with 39 additions and 38 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ export async function createUser(userData: UserCreateForm): Promise<User> {
|
|||
})
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue