Skip to content

Commit

Permalink
add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchfield committed Mar 7, 2024
1 parent 2ceb58d commit a410e52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions PowerShell/ScubaGear/Modules/Support/Support.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ function Initialize-SCuBA {
$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

# Need to determine where module is so we can get required versions info
$ModuleBaseDir = Split-Path -Path (Get-Module ScubaGear).Path -Parent
$RequiredModulesPath = Join-Path -Path $ModuleBaseDir -ChildPath "RequiredVersions.ps1"
if (Test-Path -Path $RequiredModulesPath -PathType Leaf) {
$ModuleParentDir = Split-Path -Path (Get-Module ScubaGear).Path -Parent

try {
($RequiredModulesPath = Join-Path -Path $ModuleParentDir -ChildPath 'RequiredVersions.ps1') *> $null
. $RequiredModulesPath
}
else {
throw "Unable to location RequiredVersions.ps1 at $RequiredModulesPath"
catch{
throw "Unable to find RequiredVersions.ps1 in expected directory:`n`t$ModuleParentDir"
}

if ($ModuleList) {
Expand Down

0 comments on commit a410e52

Please sign in to comment.