spago icon indicating copy to clipboard operation
spago copied to clipboard

spago.yaml json errors could be a bit smaller

Open flip111 opened this issue 2 years ago • 2 comments

❌ Couldn't parse Spago config, error:
  An error occurred while decoding a JSON value:
  Under 'Config':
  At object key package:
  Under 'PackageConfig':
  At object key publish:
  Under 'PublishConfig':
  At object key license:
  No value was found.

Instead:

Missing the following value: package - publish - license

flip111 avatar Oct 08 '23 13:10 flip111

By the way for location the error is much nicer

Need to specify a publish.location field.

So i guess for license it could be

Need to specify a publish.license field.

but for both i would make it the full path:

Need to specify a package.publish.license field.

And I'm not sure if grammatically it's a full sentence (verb need without subject who?), some alternatives:

Specify a package.publish.license field.
You need to specify a package.publish.license field.
Please specify a package.publish.license field.
A package.publish.license field needs to be specified.
A package.publish.license field needs to be given.
package.publish.license is missing, please specify it.

flip111 avatar Oct 08 '23 13:10 flip111

"Json errors" is unfortunately not a simple problem to solve.

We parse the Yaml through Argonaut, which returns us a JsonDecodeError - right now we are using the default renderer to print out the errors, and things could be improved by:

  1. writing our custom renderer so that we improve errors in general
  2. or pattern matching on a specific error so we can give even more detailed instructions

I'm not likely to get to this myself soon, but I'd love to merge a contribution for this

f-f avatar Oct 14 '23 11:10 f-f