Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 831 Bytes

File metadata and controls

30 lines (23 loc) · 831 Bytes

Recoverable Errors in Rust

This folder demonstrates handling recoverable errors in Rust, especially with file operations.

Topics Covered

  • Using Result and match for error handling
  • Handling file open and creation errors
  • Matching on error kinds (e.g., NotFound)

Key Concepts

  • Result<T, E>: Used for recoverable errors, allows handling different error cases
  • ErrorKind: Enum for different types of I/O errors
  • Graceful error handling and file creation

Example Highlights

  • Attempt to open a file, create if not found
  • Match on error kind to handle specific cases
  • Panic only for truly unrecoverable errors

Error Chances

  • File not found or cannot be created
  • Other I/O errors

Usage

cargo run
cargo check

See src/main.rs for code examples and comments explaining each concept.