JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Error contract: exceptions and “error as a value”

    Kotlin SELF
    40 level,0 lecture
    We break down how to design an “error contract” in Kotlin: when exceptions are appropriate, and when it’s better to return an error as a value via a sealed class with variants Ok/ Error. We also study fail-fast checks require(...) and check(...), the limitations of the null approach, and how to tie an error policy to application layers (CLI / domain / storage), reinforcing everything with the remove command as an example.
    Open
  • try/catch as an expression

    Kotlin SELF
    40 level,1 lecture
    We break down the idiomatic Kotlin approach: the try/ catch construct returns a value and can be used as an expression (like if and when). Using practical CLI parsing examples, we learn how to obtain Int or Int?, do an early return, write multiple catch blocks in the correct order, keep the “dangerous section” narrow, and apply finally correctly. At the end: common mistakes and style for Kotlin 2.3.
    Open
  • Custom exceptions and root cause

    Kotlin SELF
    40 level,2 lecture
    We break down why an application needs “custom” exceptions, why it is important not to lose the root cause ( cause), how to do wrapping correctly (caught → added context → rethrown), and how require()/ check() differ from domain errors. We will practice the technique on a mini app, an “expense tracker”, with commands add/ list/ exit and user-friendly messages.
    Open
  • Result<T> — how to store “success/error” status

    Kotlin SELF
    40 level,3 lecture
    We break down Result<T> in Kotlin as an explicit “success or error” contract: how to create results via Result.success(...) and Result.failure(...), how to extract values using getOrNull(), exceptionOrNull(), getOrElse { ... }, getOrThrow(), and also how to build CLI flows without a forest of try/ catch using onSuccess and onFailure. In practice, we show “wrapping” input errors (for example, NumberFormatException) and common pitfalls when people start using Result as a “problem muffler.”
    Open
  • runCatching: try/catch, onSuccess/onFailure

    Kotlin SELF
    40 level,4 lecture
    We break down how runCatching wraps try / catch into Result<T>, how to safely extract a value via getOrNull(), getOrElse { ... }, getOrThrow(), and how to use onSuccess { ... }/ onFailure { ... } for side effects. Using a CLI command-parsing example, we show where runCatching simplifies code and where it leads to “swallowing” errors—and when an honest try / catch reads better.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush