Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Language Reference Guide
    • Readme
    • Types in the Nu Language
      • Basic Types
        • Any
        • Boolean
        • Integer
        • Float
        • Filesize
        • Duration
        • Datetime
        • Range
        • String
        • Record
        • List
        • Table
        • Closure
        • Nothing
        • Binary
        • Glob
        • Cell-Path
      • Other Data Types

        • Types that cannot be used to declare variables
          • Path
        • Types which are not declarable
          • Error
          • CustomValue
          • Block
      • Type signatures
      • Commands that interact with types
    • Operators
    • Flow control
      • if/else
      • loop
      • while
      • match
      • try/catch
      • break
      • return
      • continue
    • Filters
      • each and par-each
      • Filters to select subsets of data
      • where and filter
      • Understanding the difference between get and select
    • Custom Commands
    • Declarations
    • Variable Scope
    • Strings and Text Formatting
    • Helpers and debugging commands
    • Pipelines
    • MIME Types for Nushell

Error

Description:The data type generated by the error make command and other internal commands when an error condition occurs.
Annotation:error
Literal syntax:None
Casts:error make (see below)

Additional Language Notes

  1. While error may be used as a type annotation, there is currently no known use-case for doing so, since an error value can never be assigned to a variable or custom command parameter. Any error condition results in termination of the current command/expression and will also terminate any assignment expression or custom command. For example:

    > let e: error = (error make --unspanned { msg: "This is an error" })
    Error:   × This is an error
    
    > $e
    Error: nu::shell::variable_not_found
    
    × Variable not found
       ╭─[entry #19:1:1]
    1 │ $e
       · ─┬
       ·  ╰── variable not found
       ╰────
  2. The error type is also returned from internal Nushell commands to indicate an error condition, but as with assignment, there is no way to use this result.

  3. Surrounding code that might potentially throw an error with a try/catch {|e|} block will result in an $e variable that is a record, not an error type.

Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred
Next
CustomValue