Pervaxis.Core.Exceptions 1.6.0

dotnet add package Pervaxis.Core.Exceptions --version 1.6.0
                    
NuGet\Install-Package Pervaxis.Core.Exceptions -Version 1.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pervaxis.Core.Exceptions" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pervaxis.Core.Exceptions" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Pervaxis.Core.Exceptions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pervaxis.Core.Exceptions --version 1.6.0
                    
#r "nuget: Pervaxis.Core.Exceptions, 1.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pervaxis.Core.Exceptions@1.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pervaxis.Core.Exceptions&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Pervaxis.Core.Exceptions&version=1.6.0
                    
Install as a Cake Tool

Pervaxis.Core.Exceptions

Structured exception handling with a structured exception envelope, compact exception IDs, and domain-specific exception types. Implements Section 15 of the Pervaxis Platform Spec.

Installation

dotnet add package Pervaxis.Core.Exceptions

Registration

builder.Services.AddPervaxisExceptions(options =>
{
    options.ServiceName = "order-service";
    options.Environment = builder.Environment.EnvironmentName;
});

Exception Envelope

Every exception carries a consistent envelope:

Field Example
ExceptionId ex_a1b2c3d4e5f67890
Context Structured request and service metadata
CorrelationId 3fa85f64-5717-4562-b3fc-2c963f66afa6
TraceId OpenTelemetry trace ID
TenantId tenant-abc
UserId user-xyz
ServiceName order-service
Environment production
Severity High
Category Infrastructure
IsRetryable true
RequiresHumanIntervention false
CustomerMessage Safe, sanitized message for external callers
TechnicalDetail Full internal detail
StackTrace Captured internal stack trace
ErrorCode Stable machine-readable error code
IsCustomerMessageSafe true for externally safe messages
IsTechnicalDetailSafe false for technical detail by default
OccurredAt UTC timestamp

Exception Presentation

The package exposes typed contracts for transport-specific rendering:

  • IExceptionPresenter
  • ExceptionRestProblemDetails
  • ExceptionGraphQlError
  • ExceptionGrpcStatus

Usage

Infrastructure Exceptions

// Transient - retryable (database connectivity, timeout, etc.)
throw PervaxisInfrastructureException.Transient(
    serviceName, environment,
    customerMessage: "Service is temporarily unavailable. Please retry.",
    technicalDetail: "Connection refused on PostgreSQL port 5432.",
    innerException: ex);

// Critical - requires human intervention
throw PervaxisInfrastructureException.Critical(
    serviceName, environment,
    customerMessage: "A critical platform error occurred.",
    technicalDetail: "Primary database replica set is unreachable.");

Security Exceptions

// Unauthorized - generic customer message, technical detail preserved internally
throw PervaxisSecurityException.Unauthorized(
    serviceName, environment,
    technicalDetail: "JWT expired. iss claim mismatch with tenant abc-123.");

// Forbidden - with tenant/user context for audit
throw PervaxisSecurityException.Forbidden(
    serviceName, environment,
    technicalDetail: "User role=viewer attempted DELETE /tenants/abc.",
    tenantId: tenantId.Value,
    userId: userId.Value);

Agentic Exceptions

// Low confidence - always escalates to human review
throw PervaxisAgenticException.LowConfidence(
    serviceName, environment,
    agentName: "TriageAgent",
    technicalDetail: "Confidence score 0.42, threshold 0.85.");

// Guardrail violation - critical, always requires human intervention
throw PervaxisAgenticException.GuardrailViolation(
    serviceName, environment,
    agentName: "AutomationAgent",
    violatedGuardrail: "no-production-writes",
    technicalDetail: "Attempted DELETE /tenants/abc.");

Factory (DI-integrated)

public class OrderService(IExceptionEnvelopeFactory exceptionFactory)
{
    public void ProcessOrder()
    {
        try { /* ... */ }
        catch (Exception ex)
        {
            var envelope = exceptionFactory.Create(
                ex,
                ExceptionCategory.Domain,
                ExceptionSeverity.Medium,
                customerMessage: "Order processing failed.",
                correlationId: correlationId,
                traceId: traceId);

            throw PervaxisInfrastructureException.From(envelope);
        }
    }
}

Exception ID Format

ex_{Guid:N}[..16]

Example: ex_a1b2c3d4e5f67890


Pervaxis Platform · Clarivex Technologies · https://clarivex.tech

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 126 6/6/2026