# try / catch

say it: **“TRY or KACH”** **/traɪ ɔːr kætʃ/**

Runs code and handles errors instead of crashing.

## What does `try / catch` do?

`try`/`catch` handles errors: code in `try` runs, and if a terminating error happens, `catch` runs instead of the script crashing.

```powershell
try {
    Get-Content .\settings.json -ErrorAction Stop
}
catch {
    Write-Warning "Could not read settings: $($_.Exception.Message)"
}
```

Level: Journeyman · [More PowerShell terms at this level](https://www.ask-codey.com/glossary?category=powershell&level=3)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/try-catch
