PrateekKumarSingh / AzViz

⚡ ☁ Azure Visualizer aka 'AzViz' : A #powershell module to automatically generate Azure resource topology diagrams by just typing a PowerShell cmdlet and passing the name of one or more Azure Resource groups
MIT License
584 stars 146 forks source link

fix: add check to make sure category is not null #84

Closed moiaune closed 2 years ago

moiaune commented 2 years ago

This PR adds a check to see if $toCateg is not empty or null before getting icon if the label verbosity is 2.

If there are multiple values passed to -Rows in Get-ImageNode it will try to split by / (with max 2 substrings) and format it into a string for all values after the first one. If the value cant be splitted, the formatting will fail and throw an error:

Get-ImageNode : Error formatting a string: Index (zero based) must be greater than or equal to zero and less than the size of the argument list..

In my case, when the NetworkWatcher is getting associations from an application gateway, these associations dont have a type/provider/category, and it will fail when splitting. Therefor we check to see if $toCateg is not empty or null and leave it out if it is.

this might also fix #64