aws / aws/aws-lambda-dotnet

Support PowerShell ErrorActionPreference Continue

Open
#1,093 5 comments 0 reactions 0 assignees View on GitHub
bug module/custom-runtime p2 queued
Dominant language
C#
Stars
1.7k
Forks
503
Avg merge
1d 5h
Merged PRs (30d)
18

Description


## Describe the Feature

ErrorActionPreference Continue results in the last object being returned to the caller.

ErrorActionPreference should work as you would expect if you ran your script outside of lambda. If ErrorActionPreference is set to Continue, the script should continue to execute and return the last object, not the error.

### Is your Feature Request related to a problem?

Module functions that write errors have to be suppressed using ErrorAction SilentlyContinue to prevent lambda from "giving up" on returning the last object.

## Proposed Solution

### Describe alternatives you've considered

## Additional Context

The default ErrorActionPreference in lambda is Continue however lambda is weird and it will hold on to an error and give it to the caller rather than return the last object.

It does not "throw" or "return" the error (i.e. stop execution) as you would expect in reading the documentation. The script will continue to run regardless of the error. If a script has side effects that occur after the error (like Write-S3Object) they will run.

This can mislead developers into thinking their code stopped (since they got some error early on in the script), but in reality the script continued to execute after the error.

### Environment

* [ ] :wave: I may be able to implement this feature request
* [X] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.