Skip to content

Commit

Permalink
Added logic for checking ipstack.com API Key with some error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodev1702 committed Jan 19, 2025
1 parent 288597d commit e1f7352
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Hawk/internal/functions/Get-IPGeolocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Function Get-IPGeolocation {
# Validate key format (basic check)
if ([string]::IsNullOrWhiteSpace($AccessKey)) {
Out-LogFile "API key cannot be empty or whitespace." -isError
throw | Out-Null
throw "API key cannot be empty or whitespace."
}

# If testing is requested, validate the key
Expand All @@ -55,7 +55,7 @@ Function Get-IPGeolocation {
$response = Invoke-RestMethod -Uri $testUrl -Method Get
if ($response.success -eq $false) {
Out-LogFile "API key validation failed: $($response.error.info)" -isError
throw | Out-Null
throw "API key validation failed: $($response.error.info)"
}
Out-LogFile "API key validated successfully!" -Information

Expand All @@ -64,7 +64,7 @@ Function Get-IPGeolocation {
}
catch {
Out-LogFile "API key validation failed: $_" -isError
throw | Out-Null
throw "API key validation failed: $_"

}
}
Expand All @@ -78,7 +78,7 @@ Function Get-IPGeolocation {
}
catch {
Out-LogFile "Failed to update IP Stack API key: $_" -isError
throw | Out-Null
throw "Failed to update IP Stack API key: $_"
}


Expand Down

0 comments on commit e1f7352

Please sign in to comment.