Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better error messages for toJson/fromJson problems. #37

Open
marcglasberg opened this issue Feb 8, 2024 · 1 comment
Open
Labels
triaging Initial investigation into the issue

Comments

@marcglasberg
Copy link

marcglasberg commented Feb 8, 2024

If I make a mistake when creating custom toJson/fromJson, Celest shows me this unhelpful error message:

Project has errors. Please fix them and save the corresponding files.

Example

This fromJson method has the wrong signature:

factory CashBalance.fromJson(Object? value) 
   => CashBalance(value as double);

The error should be something along the lines of: Method CashBalance.fromJson should get a "Map<String, dynamic> value)" parameter.

Example

Here I used a static method, instead of a constructor:

static CashBalance fromJson(Map<String, dynamic> value) 
   => CashBalance(value['cash']);

The error should be something along the lines of: Instead of a static method CashBalance.fromJson, please use "factory CashBalance.fromJson".

Example

If I provide the fromJson but not the toJson, I get no errors. I should get something like Since you provided CashBalance.fromJson, you should also provide CashBalance.toJson, and vice-versa.

@abdallahshaban557
Copy link
Contributor

Hi @marcglasberg - thanks for letting us know! We'll check and get back to you ASAP!

@dnys1 dnys1 added triaging Initial investigation into the issue and removed feature request labels Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaging Initial investigation into the issue
Projects
None yet
Development

No branches or pull requests

3 participants