Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created March 30, 2022 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/56d14f78b9a5d2286c9fb4c28b111a8c to your computer and use it in GitHub Desktop.
Save bielawb/56d14f78b9a5d2286c9fb4c28b111a8c to your computer and use it in GitHub Desktop.
Więcej szczegółów o błędzie.
try {
Invoke-RestMethod -Uri http://psu.contoso.com/fail -ErrorAction Stop
} catch {
$szczegółyBłędu = [IO.StreamReader]::new(
$_.Exception.Response.GetResponseStream()
).ReadToEnd()
"Błąd - $_ - $szczegółyBłędu"
}
# Wynik:
# Błąd - The remote server returned an error: (404) Not Found. - Coś nie bangla!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment