celest-dev / celest

The Flutter cloud platform
https://celest.dev
Other
232 stars 12 forks source link

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

Open marcglasberg opened 5 months ago

marcglasberg commented 5 months ago

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 commented 5 months ago

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