wilkinsona / project-generator

3 stars 4 forks source link

Validate ProjectRequest #67

Closed mbhave closed 5 years ago

mbhave commented 5 years ago

The previous API throws a InvalidProjectRequestException when the project request is invalid.

snicoll commented 5 years ago

@mbhave what do you have in mind for this? Would moving this to resolve would be the right solution? We should rename the exception then

snicoll commented 5 years ago

We had a short brainstorming about this one. ProjectRequest#resolve may generate this exception and it looks like this code will probably stick for the most part.

ProjectDescription offers a separate layer where type-safe inputs have to be provided (i.e. "maven-project" is replaced by MavenBuildSystem.class). Dependencies have to be resolved upfront as well as we use a separate type for those.

We should probably start moving that code out of ProjectRequest in a "service layer" that would invoke the new API based on the input from the web layer. It would probably be useful if we would have an easy way to intercept invalid input that are type-safe now: using the previous example, an IllegalArgumentException is thrown if the type attribute refers to an unsupported build system, it would be nice not to have to catch that to throw the higher-level exception.

A base exception was envisioned but I don't know if that's going to be helpful.

snicoll commented 5 years ago

See also https://github.com/wilkinsona/project-generator/issues/80#issuecomment-457823359