SamuraiAku / SPDX.jl

Provides for the creation, reading and writing of SPDX files in multiple file formats. Written in pure Julia.
MIT License
5 stars 1 forks source link

Error handling #36

Open SamuraiAku opened 1 year ago

SamuraiAku commented 1 year ago

When a license string has something other that WITH for the middle word, we get the following

julia> SpdxSimpleLicenseExpressionV2("MIT IS AWESOME")
WARNING:  Unable to parse License Exception ==> MIT IS AWESOME
MIT  # Returns the base license without the bad exception

This should be an error or perhaps return nothing or return a NOASSERTION license expression. Not sure, have to think about that some more.

On a related note, SpdxSimpleLicenseExpressionV2 does error out if presented with an empty license string is presented. Is that perhaps too harsh? Should it return nothing instead or NOASSERTION?

Returning nothing would have to be coordinated with PkgToSoftwareBOM.jl to make sure that nothing there gets broken.

SamuraiAku commented 1 year ago

Similarly for SpdxTimeV2, it unintentionally throws an exception when the time string is malformed

julia> SpdxTimeV2("2022-05-15T15:05:02P")
WARNING: SPDX creation date may not match the specification
ERROR: ArgumentError: Unable to parse string "2022-05-15T15:05:02P" using format dateformat"yyyy-mm-ddTHH:MM:SSZ". Unable to parse date time. Expected directive DatePart(Z) at char 20
Stacktrace:

Instead of just firing off a println(). But what is the right way to handle this situation?

SamuraiAku commented 1 year ago

SpdxPackageExternalReferenceV2 returns nothing when there is an error in the input string. That would cause a failure when building SpdxPackage because you can't put nothing in a Vector{SpdxPackageExternalReferenceV2}