Skip to content

Latest commit

 

History

History
138 lines (95 loc) · 5.19 KB

013-custom-exception-on-all-sdks.md

File metadata and controls

138 lines (95 loc) · 5.19 KB

Add Custom Exceptions on All SDKs

Summary

All Appwrite SDKs instead of exposing the internal details via existing exceptions, we want to throw custom AppwriteException. This will make it a lot easier for anyone using the SDK to understand the errors as all SDKs will have similar error response, as they all have same success response.

Problem Statement (Step 1)

What problem are you trying to solve?

Right now, whenever there's error on Appwrite SDK, each throw platform exceptions. Each are different based on the platform. There should be unified experience in Appwrite SDK in whichever platforms we use. Introducing AppwriteException will resolve this issue.

What is the context or background in which this problem exists?

We have multiple platform SDK each provide error information in different way. So we want to introduce unified way to throw errors accross multiple SDKs

Once the proposal is implemented, how will the system change?

All the SDKs will implement new AppwriteException class and throw AppwriteException with error details for all kinds of errors.

Design proposal (Step 2)

AppwriteException Class

In each SDK implement AppwriteException class that should provide following details

  1. Message string
  2. Error code (mostly http status code)
  3. Appwrite server response data

Handle Errors

Every server call in Appwrite SDKs should handle error cases and throw AppwriteException with appropriate details.

Exception Information in Docs

The information regarding exceptions thrown, should be in the Appwrite SDKs docs for each SDK. Most SDKs have doc comments where we could include these or can create separate DOCs that will be generated for the SDK. The Appwrite DOCs should also include information about these errors with details on what information are returned, like the response value in the docs. The DOCs should include

  • What exceptions can a method throw
  • What are possible error codes and error messages
  • What do they mean, and how to debug
  • The exception information should be like response information in the DOCs, should include what structure and fields are available

Error information in Swagger

The error info in Swagger spec will be under responses and can look like this

{
  "responses": {
    "200": {
      "description":"This is success response"      
    },
    "400": {
      "description": "Bad Request. User ID must be provided",
      "schema": {
        "$ref":"#definitions/bad_request"
      }
    }
  }
}

Prior art

Unresolved questions

Future possibilities