🚀 Feature: Constants for Error Types
Maintainer thường phản hồi trong vòng 1 ngày
@stnguyen90 đang làm issue này rồi.
Từ ngày 9/10/2023.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
🔖 Feature description
For the error types exposed here we should have a class with constants or an enum so we don't have to manually put the string in the code.
🎤 Pitch
Let say I want to display some error message specifically to the user depending on the type, so instead of doing this:
AppWriteException exception;
if (exception.type == 'user_already_exists') {
...
}
I could use the constant instead
AppWriteException exception;
if (exception.type == ErrorType.userAlreadyExists) {
...
}
Requirements
To implement this, we'll need to update the API specs to include the error types. For the API specs, we'll want to add an AppwriteException schema/definition like so:
"definitions": {
"appwriteException": {
"properties": {
"message": {
"type": "string",
"description": "Error message.",
"x-example": "Invalid id: Parameter must be a valid number"
},
"type": {
"type": "string",
"description": "Error type.",
"enum": [
"general_mock",
"general_argument_invalid"
],
"x-example": "argument_invalid"
},
"code": {
"type": "integer",
"description": "Error code.",
"x-example": 400,
"format": "int32"
}
},
"x-appwrite": {
"types": [
{
"code": 400,
"type": "general_mock",
"description": "General errors thrown by the mock controller used for testing."
},
{
"code": 400,
"type": "general_argument_invalid",
"description": "The request contains one or more invalid arguments. Please refer to the endpoint documentation."
}
]
}
},
"any": {
"description": "Any",
"type": "object",
"additionalProperties": true
},
Note:
- this is an example for Swagger 2. The equivalent will need to be done for OpenAPI 3
- we're still finalizing whether was want the types in
definitions.appwriteExceptionordefinitions.appwriteException.properties.types
The SDK Generator should use the API specs to generate the enums with descriptions like:
enum ErrorType {
/**
* General errors thrown by the mock controller used for testing.
*/
GeneralMock = "general_mock",
/**
* The request contains one or more invalid arguments. Please refer to the endpoint documentation.
*/
GeneralArgumentInvalid = "general_argument_invalid"
}
enum ErrorType implements Comparable<ErrorType> {
/// General errors thrown by the mock controller used for testing.
generalMock(code: 400, type: 'general_mock'),
/// General errors thrown by the mock controller used for testing.
generalArgumentInvalid(code: 400, type: 'general_argument_invalid');
const ErrorType({
required this.code,
required this.type,
});
final int code;
final String type;
@override
int compareTo(ErrorType other) => type.compareTo(other.type);
}
So that the developer's IDE will show the description like:
Tasks
- https://github.com/appwrite/appwrite/pull/5979
- android
- cli - not needed
- dart
- deno
- dotnet
- https://github.com/appwrite/sdk-for-flutter/issues/149
- go - not ready
- graphql/docs - not needed
- kotlin
- node
- php
- python
- rest/docs - not needed
- ruby
- swift
- web
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
- Ngôn ngữ chính
- Twig
- Star
- 330
- Fork
- 212
- Merge trung bình
- 12 giờ 3 phút
- Pull request đã merge (30 ngày)
- 131
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của appwrite/sdk-generator
-
🐛 Bug Report: Execution.fromMap throws Bad state: No element when server doesn't return resourceType (pre-Sites serversCó thể làm lại được @Aakriti7-giti đã nhận 79 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
appwrite/sdk-generator#1858 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Generate Push by default for SDKs that already released itCó thể làm lại được @ChiragAgg5k đã nhận 34 ngày trước và không có pull request nào đang mở. Đang mở
appwrite/sdk-generator#2043 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
appwrite/sdk-generator#1996 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
appwrite/sdk-generator#1851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
📚 Documentation: Add Vale linting for all generated docs and examplesCó thể đã có người làm @kekubhai đã nhận 74 ngày trước. Đang mở
appwrite/sdk-generator#1822 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày