Skip to content

Commit 68a95fa

Browse files
committed
Silent error handling in scripts
Silent error handling added to integration scripts so that errors aren't displayed each time the integrations are rerun.
1 parent 9df4388 commit 68a95fa

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Cognifide.PowerShell/Data/serialization/master/sitecore/system/Modules/PowerShell/Script Library/Platform/Internal/Integrations/Content Editor Gutter.item

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ templatekey: PowerShell Script
1313
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
1414
name: Script
1515
key: script
16-
content-length: 2875
16+
content-length: 2935
1717

1818
$gutterPath = "core:/sitecore/content/Applications/Content Editor/Gutters/"
1919
$gutterHandlerClass = "Cognifide.PowerShell.Integrations.Gutters.GutterStatusRenderer, Cognifide.PowerShell"
@@ -30,7 +30,7 @@ foreach($root in $roots){
3030
$script = $_
3131
Write-Host "Processing Script '$($script.Name)'"
3232
$gutterEntryPath = "$gutterPath$($script.Name)"
33-
$gutterEntry = Get-Item $gutterEntryPath
33+
$gutterEntry = Get-Item $gutterEntryPath -ErrorAction SilentlyContinue
3434
if($gutterEntry -eq $null){
3535
Write-Host "Adding new script '$($script.Name)' to gutter." -ForegroundColor Green
3636
$gutterEntry = New-Item $gutterEntryPath -ItemType $gutterTemplate
@@ -61,7 +61,7 @@ Get-Childitem $gutterPath | ForEach-Object {
6161
if ($scriptDb -eq $null){
6262
$scriptDb = "master"
6363
}
64-
$script = Get-Item -path "$($scriptDb):/" -ID $scriptId
64+
$script = Get-Item -path "$($scriptDb):/" -ID $scriptId -ErrorAction SilentlyContinue
6565
if($script -eq $null){
6666
Write-Host "Removing '$($gutterEntry.Name)' from gutter as the script no longer exists or module not active."
6767
$gutterEntry | remove-item
@@ -86,7 +86,7 @@ Control/32x32/treeview.png
8686
----version----
8787
language: en
8888
version: 1
89-
revision: 194910fa-051f-4fb5-b58a-9f366878110f
89+
revision: 6e750e8c-c9df-4819-afec-2dc7de8deb0e
9090

9191
----field----
9292
field: {25BED78C-4957-4165-998A-CA1B52F67497}
@@ -101,14 +101,14 @@ name: __Revision
101101
key: __revision
102102
content-length: 36
103103

104-
194910fa-051f-4fb5-b58a-9f366878110f
104+
6e750e8c-c9df-4819-afec-2dc7de8deb0e
105105
----field----
106106
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
107107
name: __Updated
108108
key: __updated
109109
content-length: 34
110110

111-
20150105T110540:635560527406969297
111+
20150831T231701:635766598217345935
112112
----field----
113113
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
114114
name: __Updated by

Cognifide.PowerShell/Data/serialization/master/sitecore/system/Modules/PowerShell/Script Library/Platform/Internal/Integrations/Content Editor Ribbon.item

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ content-length: 52
2929
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
3030
name: Script
3131
key: script
32-
content-length: 6086
32+
content-length: 6206
3333

3434
$stripsPath = 'core:\content\Applications\Content Editor\Ribbons\Strips'
3535

@@ -44,7 +44,7 @@ foreach($root in $roots){
4444
#Adding missing strips
4545
Get-Childitem $scriptLibPath | ? { $_.TemplateName -eq "PowerShell Script Library" } | % {
4646
$scriptLibrary = $_;
47-
$strip = Get-Item "$stripsPath/$($scriptLibrary.Name)"
47+
$strip = Get-Item "$stripsPath/$($scriptLibrary.Name)" -ErrorAction SilentlyContinue
4848
if($strip -eq $null){
4949
Write-Host "Adding Strip '$($scriptLibrary.Name)'." -f Green
5050
$strip = New-Item -path "$stripsPath" -Name "$($scriptLibrary.Name)" -ItemType "System/Ribbon/Strip"
@@ -54,7 +54,7 @@ foreach($root in $roots){
5454
# Adding missing chunks
5555
Get-Childitem $scriptLibrary.ProviderPath | ForEach-Object {
5656
$chunkLibrary = $_
57-
$chunk = Get-Item "$stripsPath/$($scriptLibrary.Name)/$($chunkLibrary.Name)"
57+
$chunk = Get-Item "$stripsPath/$($scriptLibrary.Name)/$($chunkLibrary.Name)" -ErrorAction SilentlyContinue
5858
if($chunk -eq $null){
5959
Write-Host "Adding Chunk '$($chunkLibrary.Name)'." -f Green
6060
$chunk = New-Item -path "$($strip.ProviderPath)" -Name "$($chunkLibrary.Name)" -ItemType "System/Ribbon/Chunk"
@@ -72,7 +72,7 @@ foreach($root in $roots){
7272
Get-Childitem $chunkLibrary.ProviderPath | ForEach-Object {
7373
$script = $_
7474
if($script.TemplateName -eq "PowerShell Script"){
75-
$button = Get-Item "$($chunk.ProviderPath)/$($script.Name)/$($script.Name)"
75+
$button = Get-Item "$($chunk.ProviderPath)/$($script.Name)/$($script.Name)" -ErrorAction SilentlyContinue
7676
if($button -eq $null){
7777
$panel = New-Item -path "$($chunk.ProviderPath)" -Name "$($script.Name)" -ItemType "System/Ribbon/Panel"
7878
$panel.Type = "Cognifide.PowerShell.Client.Controls.ContentEditorRibbonPanel,Cognifide.PowerShell"
@@ -117,7 +117,7 @@ Get-Childitem $stripsPath | ForEach-Object {
117117
$message = [Sitecore.Web.UI.Sheer.Message]::Parse($null,$button.Click)
118118
$scriptDb = $message.Arguments["scriptDb"]
119119
$scriptId = $message.Arguments["script"];
120-
$script = Get-Item "$($scriptDb):/" -Id $scriptId
120+
$script = Get-Item "$($scriptDb):/" -Id $scriptId -ErrorAction SilentlyContinue
121121
if($button.ID -eq $panel.Id)
122122
{
123123
$panel | remove-item -Recurse
@@ -160,7 +160,7 @@ Control/16x16/toolbar.png
160160
----version----
161161
language: en
162162
version: 1
163-
revision: 0d70bfd7-be3a-4bdf-b9cc-86884854bfcd
163+
revision: 64be6aec-c0c8-46b7-9ae2-7f5de25abd8a
164164

165165
----field----
166166
field: {25BED78C-4957-4165-998A-CA1B52F67497}
@@ -175,14 +175,14 @@ name: __Revision
175175
key: __revision
176176
content-length: 36
177177

178-
0d70bfd7-be3a-4bdf-b9cc-86884854bfcd
178+
64be6aec-c0c8-46b7-9ae2-7f5de25abd8a
179179
----field----
180180
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
181181
name: __Updated
182182
key: __updated
183-
content-length: 15
183+
content-length: 34
184184

185-
20150820T230141
185+
20150831T231817:635766598979241887
186186
----field----
187187
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
188188
name: __Updated by

0 commit comments

Comments
 (0)