Skip to content
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

Closed
2 tasks done
ferventcoder opened this issue Feb 26, 2015 · 5 comments
Closed
2 tasks done

Write-ChocolateyFailure Fixes #122

ferventcoder opened this issue Feb 26, 2015 · 5 comments

Comments

@ferventcoder
Copy link
Member

  • Do not call Write-ChocolateyFailure from Chocolatey functions.
  • Write-ChocolateyFailure should still throw an error for compatibility reasons. This is a bug causing nothing to be thrown as an error when called directly.
@ferventcoder ferventcoder self-assigned this Feb 26, 2015
@ferventcoder ferventcoder added this to the 0.9.9 milestone Feb 26, 2015
@ferventcoder ferventcoder changed the title Remove deprecated functions in POSH Remove deprecated functions in PowerShell Feb 26, 2015
@ferventcoder ferventcoder changed the title Remove deprecated functions in PowerShell Write-ChocolateyFailure Updates Feb 27, 2015
@ferventcoder ferventcoder changed the title Write-ChocolateyFailure Updates Write-ChocolateyFailure Fixes Feb 27, 2015
ferventcoder added a commit to ferventcoder/choco that referenced this issue Feb 27, 2015
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.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Feb 27, 2015
Even if deprecated, Write-ChocolateyFailure should still throw the
error message so that packages can error.
ferventcoder added a commit that referenced this issue Feb 27, 2015
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
ferventcoder added a commit to ferventcoder/choco that referenced this issue Feb 27, 2015
* 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
@rismoney
Copy link
Contributor

rismoney commented Mar 5, 2015

what should be done for packages that use it (most of our zipped .net apps) use it.
A common theme in packages is

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
}

@gep13
Copy link
Member

gep13 commented Mar 5, 2015

@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.

@rismoney
Copy link
Contributor

rismoney commented Mar 5, 2015

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

@gep13
Copy link
Member

gep13 commented Mar 5, 2015

@rismoney yes, that is my understanding.

@ferventcoder
Copy link
Member Author

@rismoney you can actually drop the try catch throw entirely now unless you want to do any error handling in the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants