mark-nicepants / figma2flutter

Converts design token json files to flutter
Apache License 2.0
17 stars 16 forks source link

throw exception instead of null if wrong type in BorderValue #22

Closed freemansoft closed 3 months ago

freemansoft commented 4 months ago

We want to throw if an invalid token definition was used which would be anything other than a map of the 3 attributes of "value".

  1. Border value returns null instead of throwing an exception if the value is anything other than a Map<String, ...>
  2. Retains the current behavior of returning null if null was passed in.

This causes a hard to debug later when a null check catches the null.

This code instead throws a FormatException that will get later wrapped and logged making debugging easier.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.46%. Comparing base (b20e952) to head (817346c).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #22 +/- ## ======================================= Coverage 98.46% 98.46% ======================================= Files 31 31 Lines 847 849 +2 ======================================= + Hits 834 836 +2 Misses 13 13 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

freemansoft commented 4 months ago

The previous unit test saved me from doing something stupid. Let's hear it for regression protection tests!