Badgerati / Pode.Web

Web template framework for use with the Pode PowerShell web server
MIT License
194 stars 27 forks source link

Show Error Alert when Table fails to load data from scriptblock #374

Open Badgerati opened 2 years ago

Badgerati commented 2 years ago

When building a table, if the scriptblock fails to run then an error alert should be displayed. For example, the table in the full.ps1 example to show services, when this is run on linux it just spins forever and ever, but on the terminal you see:

pode-web-example  | Date: 2022-11-06 17:51:46
pode-web-example  | Level: Error
pode-web-example  | ThreadId: 1
pode-web-example  | Server: f41c416fbc35
pode-web-example  | Category: System.Management.Automation
pode-web-example  | Message: The term 'Get-Service' is not recognized as a name of a cmdlet, function, script file, or executable program.
pode-web-example  | Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
pode-web-example  | StackTrace:    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
pode-web-example  |    at Invoke-PodeScriptBlock(Closure , FunctionContext )
pode-web-example  |    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
pode-web-example  |    at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
pode-web-example  |    at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
pode-web-example  |    at System.Management.Automation.CommandProcessorBase.Complete()
phende commented 1 year ago

What about using a placeholder rather than an alert ? If the sciptblock failed: "An error happened while retrieving the data." And if the scriptblock succeeded but did not return anything: "There is no data."