language-puppet icon indicating copy to clipboard operation
language-puppet copied to clipboard

sourceName in SourcePos is not always the expected culprit

Open PierreR opened this issue 9 years ago • 2 comments

Given a file called 'saltmaster.pp' containing these lines:

  class {
    'application::profile::puppetmaster::environments':
      evironments => $environments
  }

where I simulate an error ('evironmentsinstead ofenvironment`), I receive the following error message:

x saltmaster_dev
  The following parameters are unknown: (evironments) when including class application::profile::puppetmaster::environments at # SourcePos {sourceName = "./modules/application/manifests/profile/puppetmaster/environments.pp", sourceLine = Pos 4, sourceColumn = Pos 1}

Is is rather an inconvenience that the sourcePos describes the error as happening in the including class rather than where the error is actually happening.

Is there a quick fix for this ?

As a bit of context, I have created a shake file for checking all my catalogues. In case of error, I ideally would set the shake need (the dependencies) onto the culprit file only. The first 'headache' with this is that language-puppet does not expose a structure Error type, just a Doc PrettyError. Then the second issue is the return SourcePos as explain above.

PierreR avatar Aug 12 '16 14:08 PierreR

I don't think it's easy to fix it properly. This is one of the most tangled parts of the code, as the "current position" is kept in the state monad. IIRC, it used to work as you expected, but then another error message was not at the right place ... I'll look into it anyway.

bartavelle avatar Aug 16 '16 07:08 bartavelle

It is neither urgent or such a big deal for me.

PierreR avatar Aug 16 '16 13:08 PierreR