← All compilation units

Flyology.HTTP.Server.Middleware_Errors

Description

Configures safe application exception handling for one middleware type. Protocol, timeout, cancellation, resource, and transport failures are logged distinctly and re-raised. Map may turn expected application exceptions into a response. Unexpected exceptions become a generic closing 500 before response start; partial responses are failed and closed.

App_Context

type App_Context is limited private;

Application context shared by middleware and endpoints.

Call

procedure Call
  (Context : in out App_Context;
   X       : in out Flyology.HTTP.Server.Applications.Exchange;
   Next    : in out Components.Next_Handler)

Error-handling middleware component.

Parameters
Context

Typed application context

X

Borrowed request exchange

Next

Borrowed downstream continuation

Components

with package Components is new
  Flyology.HTTP.Server.Middleware (App_Context);

Typed middleware package for App_Context.

Log

procedure Log
(Kind  : Components.Failure_Kind;
Error : Ada.Exceptions.Exception_Occurrence;
X     : in out Flyology.HTTP.Server.Applications.Exchange)

Application-provided detailed error sink.

Parameters
Kind
Error
X

Map

procedure Map
(Context : in out App_Context;
X       : in out Flyology.HTTP.Server.Applications.Exchange;
Error   : Ada.Exceptions.Exception_Occurrence;
Handled : in out Boolean)

Application-provided expected exception mapper.

Parameters
Context
X
Error
Handled