liveBook · Manning

Native error

As explained in Functional Design and Architecture: Examples in Haskell

A native error is a failure originating outside an application's framework and business logic, such as from a language ecosystem or external library.

A native error originates outside an application's framework and business logic, typically in the programming-language ecosystem or an external library. If it reaches business logic unchanged, it couples that logic to native libraries and their types. section 13.1.1

Treat native errors as boundary concerns:

  • A filesystem library may report a missing file through an exception or a native result type. section 13.1.2
  • Propagating that failure directly into business logic exposes opaque types, increases coupling, and makes testing harder. section 13.1.2
  • Layer-specific error domains contain each kind of failure behind a defined handling mechanism. section 13.1.2

Missing-file failure

A filesystem interpreter can catch a missing-file exception, carry it through an abstract filesystem language, and translate or reveal it at the appropriate boundary rather than embedding the library exception in business logic. section 13.1.2

module System.File where                          #1
  
import qualified GHC.IO.Exception as IOE          #2
  
type NativeResult a = Either IOE.IOException a    #3

The listing makes the native boundary concrete by representing a filesystem result with IOException inside NativeResult. section 13.1.2

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines native errors, traces filesystem failures through layers, and organizes handling into error domains.
Examples
Uses a missing-file exception, IOException, NativeResult, and layered filesystem propagation.
What it assumes
Builds from distinctions between errors and exceptions and from the idea of application layers.
What you can do after
Diagnose/debug with it, identify native failures and contain them at layer boundaries before they reach business logic.
How it connects
Connects native errors with exceptions, external libraries, layering, free monads, dependency inversion, and error domains.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.