🚀 Feature: Constants for Error Types
I maintainer di solito rispondono entro 1 giorno
@stnguyen90 ci sta già lavorando.
Dal 9/10/2023.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
🔖 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
- Lingua principale
- Twig
- Stelle
- 330
- Fork
- 212
- Merge medio
- 12h 3m
- PR unite (30g)
- 131
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di appwrite/sdk-generator
-
🐛 Bug Report: Execution.fromMap throws Bad state: No element when server doesn't return resourceType (pre-Sites serversForse di nuovo libera @Aakriti7-giti l’ha presa 79 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
appwrite/sdk-generator#1858 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Generate Push by default for SDKs that already released itForse di nuovo libera @ChiragAgg5k l’ha presa 34 giorni fa e non c’è nessuna pull request aperta. Aperta
appwrite/sdk-generator#2043 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
appwrite/sdk-generator#1996 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
appwrite/sdk-generator#1851 ·
I maintainer di solito rispondono entro 1 giorno
-
📚 Documentation: Add Vale linting for all generated docs and examplesForse già presa @kekubhai l’ha presa 74 giorni fa. Aperta
appwrite/sdk-generator#1822 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno