PoshCode / ErrorView

An attempt to simplify and customize error views
MIT License
13 stars 0 forks source link

`ErrorView` should support a custom ErrorView #4

Open StartAutomating opened 1 month ago

StartAutomating commented 1 month ago

It would be nice if the error view was easy to customize.

Here's a slight suggestion as to how:

If $env:ErrorView is set, it should be treated as an expandable PowerShell string.

If it is present, it should take precedence over #2 and #3 .

Jaykul commented 1 month ago

Obviously, the whole point of the module is for the ErrorView to be easy to customize, and I think it already is:

  1. Write a function ConvertTo-WhateverErrorview that takes n $InputObject parameter of type [System.Management.Automation.ErrorRecord]
  2. Call Set-ErrorView Whatever or Import-Module ErrorView -Args Whatever

Additionally, the module already supports an ErrorView argument at import, and although it would be simple to make that consider an environment variable, I'm not sure I see the need, since you have to define a function anyway.

I can't imagine any useful way to format an error with a single string, so would you care to give an example?