Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
- Should refer to a valid line and char number in the usercode in the error message instead of in the powershell manager code
- Not not refer to throw $_.Exception.InnerException in the error message
-
1
-
Windows 2016-09-07, Modules 2016-09-21
Description
As part of MODULES-3443, the error code handling was improved to make it easier for users to determine where errors originate from. This code covered exceptions but syntax errors still result in a somewhat ambiguous source.
e.g.
Manifest - Fail to close the if statement with a closing '}'
exec { 'cwd test':
|
command => "\$ErrorActionPreference = 'Stop';\n\n if (1 -ne 2) {\n\n Write-Host 'failwhale'\n",
|
logoutput => true,
|
provider => powershell,
|
}
|
Puppet apply error - Debug
lbnQgYmxvY2suCg1BdCBsaW5lOjg2IGNoYXI6OQ0KKyAgICAgICAgIHRocm93ICRfLkV4Y2VwdGlvbi5Jbm5lckV4Y2VwdGlvbg0KKyAgICAgICAgIH5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fg==</Property><Property Name="stdout"></Property></ReturnResult>
|
|
Debug: 2016-09-06 12:56:00 -0700 PIPE>
|
|
Debug: 2016-09-06 12:56:00 -0700 PIPE>
|
|
Debug: Wait object signaled
|
Debug: Waited 200 total milliseconds.
|
Debug: STDERR: Missing closing '}' in statement block.
|
At line:86 char:9
|
+ throw $_.Exception.InnerException
|
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Error: $ErrorActionPreference = 'Stop';
|
|
if (1 -ne 2) {
|
|
Write-Host 'failwhale'
|
returned 1 instead of one of [0]
|
Error: /Stage[main]/Main/Exec[cwd test]/returns: change from notrun to 0 failed: $ErrorActionPreference = 'Stop';
|
|
if (1 -ne 2) {
|
|
Write-Host 'failwhale'
|
returned 1 instead of one of [0]
|
Debug: Class[Main]: Resource is being skipped, unscheduling all events
|
Debug: Stage[main]: Resource is being skipped, unscheduling all events
|
Debug: Finishing transaction 51536020
|
Debug: Storing state
|
Debug: Stored state in 0.02 seconds
|
Note that it refers to throw $_.Exception.InnerException and Line 86
This ticket would be to investigate how to better present syntax errors to the user and tests for the behaviour
Attachments
Issue Links
- relates to
-
MODULES-3443 PowerShell - PowerShell Manager host will propagate user code exceptions in a misleading way
-
- Resolved
-
- links to