< Summary

Information
Class: MyNet.Primitives.Exceptions.TranslatableException
Assembly: MyNet.Primitives
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Exceptions/TranslatableException.cs
Tag: 323_28699572109
Line coverage
45%
Covered lines: 5
Uncovered lines: 6
Coverable lines: 11
Total lines: 93
Line coverage: 45.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor()100%210%
.ctor(...)100%210%
.ctor(...)100%210%
get_Message()100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Exceptions/TranslatableException.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="TranslatableException.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Collections.Generic;
 9using System.Runtime.InteropServices;
 10
 11namespace MyNet.Primitives.Exceptions;
 12
 13/// <summary>
 14/// Represents an exception that contains a resource key and format parameters intended for localization.
 15/// </summary>
 16/// <remarks>
 17/// The message passed to base <see cref="Exception"/> is formatted using the current culture and the provided parameter
 18/// </remarks>
 19[ComVisible(true)]
 20public class TranslatableException : Exception
 21{
 22    /// <summary>
 23    /// Initializes a new instance of the <see cref="TranslatableException"/> class with a specified resource key and fo
 24    /// </summary>
 25    /// <param name="resourceKey">The resource key that identifies the localized message associated with this exception.
 26    /// <param name="parameters">The parameters to be used for formatting the resource string associated with the Resour
 627    public TranslatableException(string resourceKey, params object?[] parameters)
 28    {
 29        ResourceKey = resourceKey;
 30        Parameters = parameters;
 631    }
 32
 33    /// <summary>
 34    /// Initializes a new instance of the <see cref="TranslatableException"/> class with a specified resource key, inner
 35    /// </summary>
 36    /// <param name="resourceKey">The resource key that identifies the localized message associated with this exception.
 37    /// <param name="innerException">The exception that is the cause of the current exception.</param>
 38    /// <param name="parameters">The parameters to be used for formatting the resource string associated with the Resour
 39    public TranslatableException(string resourceKey, Exception? innerException, params object?[] parameters)
 340        : base(null, innerException)
 41    {
 42        ResourceKey = resourceKey;
 43        Parameters = parameters;
 344    }
 45
 46    /// <summary>
 47    /// Initializes a new instance of the <see cref="TranslatableException"/> class with default values for ResourceKey 
 48    /// </summary>
 049    internal TranslatableException()
 50    {
 51        ResourceKey = string.Empty;
 52        Parameters = [];
 053    }
 54
 55    /// <summary>
 56    /// Initializes a new instance of the <see cref="TranslatableException"/> class with a specified error message.
 57    /// </summary>
 58    /// <param name="message">The error message that explains the reason for the exception.</param>
 59    internal TranslatableException(string message)
 060        : base(message)
 61    {
 62        ResourceKey = string.Empty;
 63        Parameters = [];
 064    }
 65
 66    /// <summary>
 67    /// Initializes a new instance of the <see cref="TranslatableException"/> class with a specified error message and a
 68    /// </summary>
 69    /// <param name="message">The error message that explains the reason for the exception.</param>
 70    /// <param name="innerException">The exception that is the cause of the current exception.</param>
 71    internal TranslatableException(string message, Exception innerException)
 072        : base(message, innerException)
 73    {
 74        ResourceKey = string.Empty;
 75        Parameters = [];
 076    }
 77
 78    /// <summary>
 79    /// Gets the resource key that identifies the localized message associated with this exception. This key will be use
 80    /// </summary>
 81    public string ResourceKey { get; }
 82
 83    /// <summary>
 84    /// Gets the parameters to be used for formatting the resource string associated with the ResourceKey. These paramet
 85    /// </summary>
 86    public IReadOnlyList<object?> Parameters { get; }
 87
 88    /// <summary>
 89    /// Gets the localized message by formatting the resource string associated with the ResourceKey using the provided 
 90    /// </summary>
 391    public override string Message => ResourceKey;
 92}
 93