Print error in a form application

When a compiled Powershell Studio application gets an error, the error is not echoed to the screen automatically which makes it really hard to troubleshoot what have gone wrong. This short solution checks for error and prints in to a textbox of some sort.
The "return" quits the function, remove it to continue.

#Paste this where error checking is wanted in the code
If ($Error) {PrintError -Error $Error; Return}

#Function to print the error
function PrintError {
	$textbox.AppendText("Exception: `t$($Error[0].Exception.InnerException)`n")
	$textbox.AppendText("Message: `t$($Error[0].Exception.Message)`n")
	$textbox.AppendText("Name: `t`t$($Error[0].Exception.TargetSite.Name)`n")
	$textbox.AppendText("Reason: `t`t$($Error[0].CategoryInfo.Reason)`n")
	$textbox.AppendText("Category: `t$($Error[0].CategoryInfo.Category)`n")
	$textbox.AppendText("TargetName: `t$($Error[0].CategoryInfo.TargetName)`n")
	$textbox.AppendText("TargetType: `t$($Error[0].CategoryInfo.TargetType)`n`n")

SAPIEN Powershell Studio, hide a form

A solution for SAPIEN PowerShell Studio to only show a form in systray and not in taskbar or in Alt+Tab.
After you create a SystemTrayMenu and SystemTrayIcon, then:

Select the form. -> ShowInTaskbar = False
And then in the code. -> $FormName.FormBorderStyle = 'FixedToolWindow'