Skip to content

Elmah.Contrib.WebApi

reference
1 min readUpdated

Kind: Service

Source: Pams/API/Pams.API/Pams.API.csproj (line 1)

Part of: Pams

NuGet package dependency

Elmah.Contrib.WebApi is a NuGet package dependency in the Pams API project that connects ELMAH error logging to ASP.NET Web API request handling. It records unhandled API errors so they can be reviewed through the application's ELMAH configuration and error log endpoint.

Diagram

mermaid
flowchart TD
    Client[API Client] --> WebApi[ASP.NET Web API]
    WebApi --> Endpoint[API Endpoint]
    Endpoint -->|Unhandled error| Elmah[Elmah.Contrib.WebApi]
    Elmah --> ErrorLog[ELMAH Error Log]

Usage

ts
async function loadPamsData() {
  const response = await fetch("/api/pams");

  if (!response.ok) {
    throw new Error(`Pams API request failed: ${response.status}`);
  }

  return response.json();
}

loadPamsData().catch((error) => {
  console.error("API request failed", error);
  // Unhandled server-side API errors are recorded by Elmah.Contrib.WebApi.
});

AI Coding Instructions

  • Keep Elmah.Contrib.WebApi referenced as a NuGet dependency in Pams.API.csproj.
  • Configure ELMAH in the API host so Web API exceptions are passed to the configured error log.
  • Do not expose ELMAH error details directly in API responses; return the application's standard error response instead.
  • Test error logging with a controlled unhandled API exception after changing Web API exception handling or ELMAH configuration.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Injected or called by (1)

  • Pams.APIPams/API/Pams.API/Pams.API.csproj:1

Was this page helpful?

Download as PDF