W3cubDocs

/Nushell

try for core

Try to run a block, if it fails optionally run a catch block.

Signature

> try {flags} (try_block) (catch_block)

Parameters

  • try_block: block to run
  • catch_block: block to run if try block fails

Input/output types:

input output
any any

Examples

Try to run a missing command

>try { asdfasdf }

Try to run a missing command

>try { asdfasdf } catch { 'missing' }
missing

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/try.html