-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write-ChocolateyFailure Fixes #122
Comments
This moves to throwing or rethrowing exceptions instead of using Write-ChocolateyFailure. Write-ChocolateyFailure is deprecated and due to be removed, so remove it from Chocolatey methods.
Even if deprecated, Write-ChocolateyFailure should still throw the error message so that packages can error.
GH-122 - Fix mistakes on throw (doesn't accept two parameters). GH-125 - `Install-ChocolateyDesktopLink` will warn instead of throw if targetPath doesn't exist - `Install-ChocolateyDesktopLink` will create the desktop directory if it doesn't exist - `Install-ChocolateyShortcut` wil create the shortcutDirectory if it doesn't exist - `Install-ChocolateyShortcut` will warn instead of throw if targetPath doesn't exist - `Install-ChocolateyShortcut` will warn instead of throw if iconlocation doesn't exist - `Install-ChocolateyShortcut` will create the workingDirectory instead of throwing an error if it doesn't exist - `Install-ChocolateyShortcut` will not try to set description if it is null
* stable: (chocolateyGH-124) Install extensions (chocolateyGH-124) Load PowerShell extensions if present (chocolateyGH-122)(chocolateyGH-125) Throw fixes / Shortcut enhancements (maint)(log) Get-BinRoot friendly deprecation (maint)(posh) Ensure Module loading preference (chocolateyGH-122) Write-ChocolateyFailure throw (chocolateyGH-122) Remove usage of Write-ChocolateyFailure (chocolateyGH-120) ChocolateyPackageFolder env var wrong
what should be done for packages that use it (most of our zipped .net apps) use it. this is our most common package structure: try {
$packageName='myapp'
$url = 'http://chocopackages.example.com/apps/myapp.zip'
$zpwd = 'D:\chocopkg\myapp\'
#------------ UNZIP myapp in D drive-------------#
Install-ChocolateyZipPackage $packageName $url $zpwd
Write-ChocolateySuccess $packageName
} catch {
Write-ChocolateyFailure $packageName $($_.Exception.Message)
throw
} |
@rismoney have a look at the guidance here: https://github.com/chocolatey/choco/wiki/HelpersReference. i.e. it will be very similar, to what you already have, in terms of structure. |
thanks for quick reply! I realize i can get this down to 1 line since it is an installchocolateyzippackage, (contrived example). but if iiuic, can i simply remove the write-chocolatey* functions, since this will be handled by choco internally.(in real cases where i have the try/catch/throw |
@rismoney yes, that is my understanding. |
@rismoney you can actually drop the try catch throw entirely now unless you want to do any error handling in the package. |
Write-ChocolateyFailure
from Chocolatey functions.The text was updated successfully, but these errors were encountered: