Added Error messages to the Try/Catch blocks
This commit is contained in:
parent
e0fa5fa74c
commit
dd918401f8
1 changed files with 8 additions and 4 deletions
|
@ -19,6 +19,7 @@
|
||||||
# WANT_JSON
|
# WANT_JSON
|
||||||
# POWERSHELL_COMMON
|
# POWERSHELL_COMMON
|
||||||
|
|
||||||
|
|
||||||
$params = Parse-Args $args;
|
$params = Parse-Args $args;
|
||||||
|
|
||||||
$result = New-Object psobject @{
|
$result = New-Object psobject @{
|
||||||
|
@ -47,7 +48,8 @@ If (-Not (Test-Path $dest -PathType Container)){
|
||||||
New-Item -itemtype directory -path $dest
|
New-Item -itemtype directory -path $dest
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
Fail-Json $result "Error creating $dest directory"
|
$err_msg = $_.Exception.Message
|
||||||
|
Fail-Json $result "Error creating $dest directory! Msg: $err_msg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +65,8 @@ If ($ext -eq ".zip" -And $recurse -eq $false) {
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
Fail-Json $result "Error unzipping $src to $dest"
|
$err_msg = $_.Exception.Message
|
||||||
|
Fail-Json $result "Error unzipping $src to $dest! Msg: $err_msg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Requires PSCX
|
# Requires PSCX
|
||||||
|
@ -107,11 +110,12 @@ Else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
|
$err_msg = $_.Exception.Message
|
||||||
If ($recurse) {
|
If ($recurse) {
|
||||||
Fail-Json $result "Error recursively expanding $src to $dest"
|
Fail-Json $result "Error recursively expanding $src to $dest! Msg: $err_msg"
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
Fail-Json $result "Error expanding $src to $dest"
|
Fail-Json $result "Error expanding $src to $dest! Msg: $err_msg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue