{"id":10221,"date":"2006-06-21T01:12:00","date_gmt":"2006-06-21T01:12:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2006\/06\/21\/errorviewcategoryview\/"},"modified":"2019-02-18T13:21:40","modified_gmt":"2019-02-18T20:21:40","slug":"errorviewcategoryview","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/errorviewcategoryview\/","title":{"rendered":"$ERRORVIEW=&#034;CATEGORYVIEW&#034;"},"content":{"rendered":"<p><font face=\"Arial\" size=\"2\">&lt;Edited 7\/2\/2006 with tags and categories&gt;<br \/>PSMDTAG:FAQ: What is $ErrorView?<br \/>PSMDTAG:FAQ: How do I get error details?<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">Have you tried out $ErrorView=&#8221;CategoryView&#8221; yet?&nbsp;<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">Remember &#8211;&nbsp; errors are just objects.&nbsp; Given that they are objects, we&nbsp;render a subset of their properties to the console.&nbsp; <\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">We provide 2 views: Normal and &#8220;CategoryView&#8221;.&nbsp; The normal view provides semi-verbose details of what went wrong where.&nbsp; This is great for beginners and casual users.&nbsp; <\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">That said, if you are an production operator and are doing the same tasks over and over day in and day out, you are going to have a well known set of errors that you encounter and this verbosity can be a problem.&nbsp; That is why we have categoryView.&nbsp;(This is another one of those features that fall into the bucket of &#8220;We want to be as <strong>Production-Oriented<\/strong> as the AS400\/CL and VMS DCL&#8221;.)<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">PSMDTAG:PHILOSOPHY:&nbsp; Provide users the option of being pithy or verbose.<br \/>PSMDTAG:PHILOSOPHY:&nbsp; Remember that some your users will be working on machines doing business worth millions or billions &#8211; code accordingly.<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">When you have CategoryView, we map all errors to a fixed set of pithy, structured, parameterized&nbsp;errors that are easy to parse visually and understand what is going on.&nbsp; It is easier to see then to explain.&nbsp; Here are 3 errors shown using the normal view:<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\"><\/font><font face=\"Courier New\" size=\"1\"><\/p>\n<p>PS&gt; asdf<br \/><font color=\"#ff0000\">&#8216;asdf&#8217; is not recognized as a cmdlet, function, operable program, or script file.<br \/>At line:1 char:4<br \/>+ asdf &lt;&lt;&lt;&lt;<\/font><br \/>PS&gt; stop-process -test<br \/><font color=\"#ff0000\">Stop-Process : A parameter cannot be found that matches parameter name &#8216;test&#8217;.<br \/>At line:1 char:18<br \/>+ stop-process -test &lt;&lt;&lt;&lt;<\/font><br \/>PS&gt; stop-process 13<br \/><font color=\"#ff0000\">Stop-Process : No process with process ID 13 was found.<br \/>At line:1 char:13<br \/>+ stop-process&nbsp; &lt;&lt;&lt;&lt; 13<\/p>\n<p><\/font><br \/><font face=\"Arial\" size=\"2\">Now we&#8217;ll switch views and show the same errors.&nbsp; Notice that you get much less info but that the info you get is very regular.&nbsp; The first field is one of about 2 dozen error categories.&nbsp; Next (in ()s) is the arguement identifer and the type of that arguement.&nbsp; Next (in []s)&nbsp; is the name of the cmdlet that was running when the error occurred.&nbsp; Last is the .NET Exception name that generated the error.<\/font><\/p>\n<p>PS&gt; $errorview<strong>=&#8221;<\/strong>CategoryView<strong>&#8220;<br \/><\/strong>PS&gt; asdf<br \/><font color=\"#ff0000\">ObjectNotFound: (asdf:String) [], CommandNotFoundException<br \/><\/font>PS&gt; stop-process -test<br \/><font color=\"#ff0000\">InvalidArgument: (:) [Stop-Process], ParameterBindingException<br \/><\/font>PS&gt; $errorview=&#8221;CategoryView&#8221;<br \/>PS&gt; stop-process 13<br \/><font color=\"#ff0000\">ObjectNotFound: (13:Int32) [Stop-Process], ProcessCommandException<br \/><\/font><\/p>\n<p><font color=\"#ff0000\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Remember that this just affects the VIEW of the error. You still have the error object in $error with all the details so if you are in categoryview and need more info you just do the following (btw: notice that you have to use -FORCE in the formatting command [the reason why would take a much longer blog to entry explain]).<\/font><\/font><\/p>\n<p><font color=\"#ff0000\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><\/font><\/p>\n<p><\/font><br \/>PS&gt; $error[0] |fl * -force<\/p>\n<p>Exception&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft.PowerShell.Commands.ProcessCommandExcepti<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; on: No process with process ID 13 was found.<br \/>TargetObject&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 13<br \/>CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ObjectNotFound: (13:Int32) [Stop-Process], ProcessC<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ommandException<br \/>FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Comma<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nds.StopProcessCommand<br \/>ErrorDetails&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>InvocationInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.Management.Automation.InvocationInfo<\/p>\n<p><font face=\"Arial\" size=\"2\">Switching back to the normal view&nbsp;can be accomplished by setting $errorview to $NULL:<\/font><\/p>\n<p>&nbsp;<\/p>\n<p>PS&gt; $errorview=$null<br \/>PS&gt; stop-process 13<br \/><font color=\"#ff0000\">Stop-Process : No process with process ID 13 was found.<br \/>At line:1 char:13<br \/>+ stop-process&nbsp; &lt;&lt;&lt;&lt; 13<br \/><\/font>PS&gt;<\/p>\n<p><font face=\"Arial\" size=\"2\">Experiment and enjoy!<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\">Jeffrey Snover<br \/>Windows PowerShell Architect<\/font><\/p>\n<p><font face=\"Arial\" size=\"2\"><br \/>PSMDTAG:ERROR: ErrorView, CategoryView<\/font><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;Edited 7\/2\/2006 with tags and categories&gt;PSMDTAG:FAQ: What is $ErrorView?PSMDTAG:FAQ: How do I get error details? Have you tried out $ErrorView=&#8221;CategoryView&#8221; yet?&nbsp; Remember &#8211;&nbsp; errors are just objects.&nbsp; Given that they are objects, we&nbsp;render a subset of their properties to the console.&nbsp; We provide 2 views: Normal and &#8220;CategoryView&#8221;.&nbsp; The normal view provides semi-verbose details of [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[30,10,11],"class_list":["post-10221","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-error","tag-faq","tag-philosophy"],"acf":[],"blog_post_summary":"<p>&lt;Edited 7\/2\/2006 with tags and categories&gt;PSMDTAG:FAQ: What is $ErrorView?PSMDTAG:FAQ: How do I get error details? Have you tried out $ErrorView=&#8221;CategoryView&#8221; yet?&nbsp; Remember &#8211;&nbsp; errors are just objects.&nbsp; Given that they are objects, we&nbsp;render a subset of their properties to the console.&nbsp; We provide 2 views: Normal and &#8220;CategoryView&#8221;.&nbsp; The normal view provides semi-verbose details of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=10221"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10221\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=10221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=10221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=10221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}