Open michaeltlombardi opened 2 months ago
@michaeltlombardi this sounds useful! Would the enum be able to specific non-sequential specific error codes? Would it be able to provide them as a negative integer or hexadecimal? ( I think "yes, yes, and yes", because it's just an [enum]
)
@StartAutomating - Yup, DSC Resources can return any valid int32 as an exit code. In this case, I'm specifically talking about the PowerShell adapter resource, which hasn't defined semantic exit codes in the resource manifest with the exitCodes
property - the resource manifest only defines success and failure:
Although as we discovered in #407 (addressed in #410), you have to specify the exit codes in the manifest as integers, you can't specify them as hexadecimals.
Summary of the new feature / enhancement
As a user and integrating vendor, I want to be able to quickly map the exit code from the PowerShell and Windows PowerShell adapters to their semantics, so I can understand what went wrong at a high-level before I investigate the error specifically.
Currently, the
Microsoft.DSC/PowerShell
andMicrosoft.Windows/WindowsPowerShell
adapters only define exit codes0
(success) and1
(error).Proposed technical implementation details (optional)
Define reusable semantic exit codes for the adapter in
psDscAdapter.psm1
and use them in the adapter code.For example,
Then, when you need to use a specific exit code:
Then we could map the exit codes to their semantic meanings and reuse errors as needed. This proposal also includes the helper function
Write-JsonMessage
for sending a JSON Line back to DSC for debug, warnings, errors, etc.While out of scope for now, we should also consider whether and how to do i18n for exit codes and error messages. In this proposal I'm just matching the use of en-US already in place for the module and adapter.