Back

sdk errors docs?

  • 0
  • React Native
  • Cloud
Ahmed CODE
6 Jun, 2024, 14:30

i'm searching for appwrite sdk erros but i didn't find any docs for it. what i find is only the api errors docs and like that.

so, where ca i find it ?

errors example: LOG [Error: AppwriteException: Missing required parameter: "secret"] LOG [Error: Error: AppwriteException: Missing required parameter: "secret"] LOG [Error: AppwriteException: Invalid token passed in the request.] LOG [Error: Error: AppwriteException: Invalid token passed in the request.]

TL;DR
Developers are facing errors when working with the SDK. The provided code snippet involves creating a user and handling various parameters. However, errors like "Invalid `queries` param" and "Missing required parameter: 'secret'" are occurring. The developer seeks SDK error documentation but has only found API error references. To address SDK errors, it is advised to check the type property and provide relevant user messages.
Ahmed CODE
6 Jun, 2024, 14:30

sdk errors docs?

Steven
6 Jun, 2024, 14:49

These are our docs on errors: https://appwrite.io/docs/advanced/platform/response-codes#error-types

It is best to check the type property and return an appropriate message to your user

Ahmed CODE
6 Jun, 2024, 14:56

I'm getting this types of error without objects:

```LOG [Error: AppwriteException: Invalid queries param: Value must a valid array no longer than 100 items and Value must be a valid string and at least 1 chars and no longer than 4096 chars]

TypeScript
code:

```js
export const createUser = async (phoneNumber, name, sex, studyRate, grade, phoneCountry, countryName, countryCode, otp) => {
    try {

        // Validate phone number
        const fixedPhoneNumber = phoneNumber.trim();
        if (!fixedPhoneNumber.startsWith('+') || fixedPhoneNumber.length > 15) {
            throw new Error('Invalid phone number format');
        }


        const newAccount = await account.createPhoneToken(ID.unique(), fixedPhoneNumber)

        if (!newAccount) throw Error

        const avatarUrl = avatar.getInitials()

        const newUser = await databases.listDocuments(config.databaseId, config.usersCollectionId, ID.unique(), {
            accountId: newAccount.$id,
            name: name,
            sex: sex,
            phoneCountry: phoneCountry,
            countryName: countryName,
            countryCode: countryCode,
            phoneNumber: fixedPhoneNumber
        })

    } catch (error) {
        console.log(error);
        throw new Error(error);
    }
}
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more