GithubHelp home page GithubHelp logo

exasol / error-reporting-csharp Goto Github PK

View Code? Open in Web Editor NEW
1.0 10.0 0.0 129 KB

C# library for describing errors

License: MIT License

C# 92.52% Python 7.48%
exasol-integration exasol error-handling error-reporting foundation-library

error-reporting-csharp's Introduction

error-reporting-csharp

.NET

Description

Contains a C# library for describing errors.

Based on https://github.com/exasol/error-reporting-java

Major difference is this library is simplified by the string interpolation feature available in the C# language.

Installation

  • Make sure you have the .NET core SDK (use the dotnet SDK installation step on GitHub runners).

  • You'll need to add the Exasol Github NuGet repository to the NuGet package manager on your local machine or the GitHub CI runner, like so:

    • On GitHub CI runners:
    dotnet nuget add source --username <username/or ci user> --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/EXASOL/index.json"
    
    • You can use a GitHub PAT on your local system:
     	dotnet nuget add source --username <username/or ci user> --password <yourPAT> --store-password-in-clear-text --name github "https://nuget.pkg.github.com/EXASOL/index.json"
    
  • You can then add the package to your projects: $ dotnet add <PROJECT> package error-reporting-csharp --version 0.2.0

Usage

Simple Messages

Simple error messages consist out of the message builder helper method which specifies an identifier and one or more messages describing the error.

ExaError.MessageBuilder("E-TEST-1").Message("Something went wrong.").ToString();

Result: E-TEST-1: Something went wrong.

String Interpolation

Since C# has string interpolation you should use that in messages and mitigations where needed, instead of parameters (which are currently not supported):

ExaError.MessageBuilder("E-TEST-2")
    .Message($"Unknown input: '{input}'.").ToString();

Result: E-TEST-2: Unknown input: 'unknown'.

Mitigations

The mitigations describe actions the user can take to resolve the error. Here is an example of a mitigation definition:

ExaError.MessageBuilder("E-TEST-2")
    .Message("Not enough space on device.")
    .Mitigation("Delete something.")
    .ToString();

Result: E-TEST-2: Not enough space on device. Delete something.

You can use string interpolation in mitigations as well.

ExaError.MessageBuilder("E-TEST-2")
    .Message($"Not enough space on device {device}.")
    .Mitigation($"Delete something from {device}.")
    .ToString();

Result: E-TEST-2: Not enough space on device '/dev/sda1'. Delete something from '/dev/sda1'.

You can chain Mitigation definitions if you want to tell the users that there is more than one solution.

ExaError.MessageBuilder("E-TEST-2")
    .Message("Not enough space on device.")
    .Mitigation("Delete something.")
    .Mitigation("Create larger partition.")
    .ToString();

Result:

E-TEST-2: Not enough space on device. Known mitigations:
* Delete something.
* Create larger partition.

Information for Users

error-reporting-csharp's People

Contributors

pj-spoelders avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

error-reporting-csharp's Issues

Add CI

Add CI on GHA to the project.

  • Don't forget to include a CI badge in the documentation as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.