ElvenScript.Error 0.0.4-beta

This is a prerelease version of ElvenScript.Error.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package ElvenScript.Error --version 0.0.4-beta
                    
NuGet\Install-Package ElvenScript.Error -Version 0.0.4-beta
                    
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="ElvenScript.Error" Version="0.0.4-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ElvenScript.Error" Version="0.0.4-beta" />
                    
Directory.Packages.props
<PackageReference Include="ElvenScript.Error" />
                    
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 ElvenScript.Error --version 0.0.4-beta
                    
#r "nuget: ElvenScript.Error, 0.0.4-beta"
                    
#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 ElvenScript.Error@0.0.4-beta
                    
#: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=ElvenScript.Error&version=0.0.4-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ElvenScript.Error&version=0.0.4-beta&prerelease
                    
Install as a Cake Tool

ElvenScript.Error

ElvenScript.Error is an .NET library for structured error and result management. It provides a consistent, extensible, and type-safe way to represent, build, and propagate errors in your applications and APIs.


Table of Contents


Features

  • Strongly-typed error representation using C# records and enums
  • Fluent ErrorBuilder for easy and safe error construction
  • Integration with ASP.NET Core via ProblemDetails
  • Support for error severity levels (Error, Warning, Info)
  • Format string validation with runtime safety and caller info in exceptions
  • Unit tested and .NET 8 ready

Installation

Add a reference to the ElvenScript.Error project or package in your solution:

If using as a project reference

<PackageReference Include="ElvenScript.Error" Version="x.y.z" />

Or clone the repository and add the project to your solution.

Usage

Basic Error Creation

using ElvenScript.Error;

var error = new Error("ERR001", ErrorSeverity.Error, "Something went wrong");
var problemDetails = error.ToProblemDetails();

Error with Formatting

using ElvenScript.Error;

var error = new Error(
    "ERR_FORMAT",
    ErrorSeverity.Warning,
    string.Format("Invalid value for field '{0}' at line '{1}'", "Name", 42)
);

Using ErrorBuilder (Fluent API)

using ElvenScript.Error;

var error = new ErrorBuilder()
    .WithCode("ERR_USER")
    .WithSeverity(ErrorSeverity.Error)
    .WithDescription("User with id {0} not found", userId)
    .Build();

Using ErrorBuilder with Direct Text

using ElvenScript.Error;

var error = new ErrorBuilder()
    .WithCode("ERR_CUSTOM")
    .WithDescriptionText("A custom error occurred.")
    .Build();

Exception Safety

If you use a format string with placeholders but do not provide arguments, the builder will throw an ArgumentException with caller info:

using ElvenScript.Error;

var error = new ErrorBuilder()
    .WithDescription("Field {0} is required");

error.Build(); // Throws ArgumentException with caller info

Project Structure

  • Error - Main error record with code, severity, and description
  • ErrorBuilder - Fluent builder for safe error creation
  • BaseError - Abstract base for custom error types
  • ErrorSeverity - Enum for error levels
  • Unit tests in Error.Tests

Contributing

Contributions are welcome! Please open issues or submit pull requests for any features, bugfixes, or improvements.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net8.0

    • No dependencies.

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