~ruther/NosSmooth

e5c6fc7958b6ae546a179bec2e175a745ef8b579 — František Boháček 3 years ago 4e64d6b
fix: return correct errors with inner results
M Core/NosSmooth.Packets/Converters/Basic/LongTypeConverter.cs => Core/NosSmooth.Packets/Converters/Basic/LongTypeConverter.cs +1 -1
@@ 19,7 19,7 @@ public class LongTypeConverter : BasicTypeConverter<long>
    {
        if (!long.TryParse(value, out var parsed))
        {
            return new CouldNotConvertError(this, value, "Could not parse as an long.");
            return new CouldNotConvertError(this, value, "Could not parse as a long.");
        }

        return parsed;

M Core/NosSmooth.Packets/Converters/Basic/UIntTypeConverter.cs => Core/NosSmooth.Packets/Converters/Basic/UIntTypeConverter.cs +1 -1
@@ 19,7 19,7 @@ public class UIntTypeConverter : BasicTypeConverter<uint>
    {
        if (!uint.TryParse(value, out var parsed))
        {
            return new CouldNotConvertError(this, value, "Could not parse as uint.");
            return new CouldNotConvertError(this, value, "Could not parse as uint");
        }

        return parsed;

M Core/NosSmooth.Packets/Converters/Special/ListTypeConverter.cs => Core/NosSmooth.Packets/Converters/Special/ListTypeConverter.cs +1 -1
@@ 65,7 65,7 @@ public class ListTypeConverter : ISpecialTypeConverter
            stringEnumerator.PopLevel();
            if (!result.IsSuccess)
            {
                return Result<object?>.FromError(new ListSerializerError(result, data.Count));
                return Result<object?>.FromError(new ListSerializerError(result, data.Count), result);
            }

            data.Add(result.Entity);

M Core/NosSmooth.Packets/Errors/CouldNotConvertError.cs => Core/NosSmooth.Packets/Errors/CouldNotConvertError.cs +2 -3
@@ 16,6 16,5 @@ namespace NosSmooth.Packets.Errors;
/// <param name="Converter">The converter that failed the parsing.</param>
/// <param name="Value">The value that failed to parse.</param>
/// <param name="Reason">The reason for the error.</param>
/// <param name="Exception">The underlying exception, if any.</param>
public record CouldNotConvertError(ITypeConverter Converter, string Value, string Reason, Exception? Exception = default)
    : ResultError($"Converter {Converter.GetType().FullName} could not convert {Value} due to {Reason}.");
\ No newline at end of file
public record CouldNotConvertError(ITypeConverter Converter, string Value, string Reason)
    : ResultError($"Converter {Converter.GetType().FullName} could not convert value \"{Value}\" due to {Reason}.");
\ No newline at end of file

Do not follow this link