Skip to content

Exceptions are hard to spot in the logs of build_runner #4127

@rrousselGit

Description

@rrousselGit

Hello!

Let's play a came of "spot the error message":

dart run build_runner watch -d
Resolving dependencies in `/Users/remirousselet/dev/rrousselGit/riverpod`... 
Downloading packages... 
Got dependencies in `/Users/remirousselet/dev/rrousselGit/riverpod`.
Resolving dependencies in `/Users/remirousselet/dev/rrousselGit/riverpod`... 
Downloading packages... 
Got dependencies in `/Users/remirousselet/dev/rrousselGit/riverpod`.
4s riverpod_generator on 17 inputs: 14 output, 3 no-op; spent 3s sdk,             
   1s analyzing                                                                   
0s source_gen:combining_builder on 46 inputs: 14 same, 32 no-op                   
4s mockito:mockBuilder on 68 inputs: 20 skipped, 48 no-op; spent 4s analyzing     
1s freezed on 160 inputs: 100 skipped, 1 output, 59 no-op                         
                                                                                  
Failed to build with build_runner in 11s with warnings; wrote 29 outputs.         
                                                                                  
log output for riverpod_generator on test/integration/generated.dart              
E InvalidTypeException: The type is invalid and cannot be converted to code.      
log output for build_runner                                                       
W Root package config not readable, manual restarts will be needed after running  
  `pub upgrade`.                                                                  
  Deleting 15 declared outputs which already existed on disk.                     

In case you missed it, that the

E InvalidTypeException: The type is invalid and cannot be converted to code.

It's pretty hard to spot one line among many others.

Some ideas to improve this are:

  • Use a different color to log user errors
  • Format them with a header corresponding to the generator name. For example:
    [my_generator]: InvalidTypeException: The type is invalid and cannot be converted to code.
  • List errors as the very last line of the logs, with a blank line separating errors from other logs

Metadata

Metadata

Assignees

Labels

type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions