Backend development

Stage 1 · Lesson 4 of 10

Exceptions and records

Your language and how HTTP works

Java has two kinds of . Checked exceptions must be caught or declared, and the compiler forces you to do it. Unchecked ones, such as IllegalArgumentException, signal bugs or bad input.

Learn try, catch and finally. Learn try-with-resources too, which closes connections and streams for you automatically. Create your own exceptions for business errors, such as OrderNotFoundException.

will later turn that into a 404 in one place. are the other half of this topic. One line, record Order(long id, BigDecimal total) {}, gives you an unchangeable data class.

It comes with a , accessors, equals, hashCode and toString already written. That makes records ideal for request and response bodies.

Common trapcatching Exception, printing the and carrying on as if nothing happened.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • GuideFree
    Dev.java: Learn Java

    Oracle · Beginner

    The official path through modern Java: records, collections, generics and exceptions

  • CourseFree
    Java Programming MOOC

    University of Helsinki · Beginner

    Free Helsinki course with hundreds of graded exercises, the best way to get fluent

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Quick syntax lookups for your language when you forget how something is written

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?