Skip to content

Commit 8050a04

Browse files
committed
Fix: Missing type information in TomlInstantiationException
1 parent cc91daa commit 8050a04

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
namespace Tomlet.Exceptions;
1+
using System;
2+
3+
namespace Tomlet.Exceptions;
24

35
public class TomlInstantiationException : TomlException
46
{
5-
public override string Message =>
6-
"Deserialization of types without a parameterless constructor or a singular parameterized constructor is not supported.";
7+
private readonly Type _type;
8+
9+
public TomlInstantiationException(Type type)
10+
{
11+
_type = type;
12+
}
13+
14+
public override string Message => $"Deserialization of types without a parameterless constructor or a singular parameterized constructor is not supported. Could not find a suitable constructor for type {_type.FullName}";
715
}

Tomlet/TomlCompositeDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private static object CreateInstance(Type type, TomlValue tomlValue, TomlSeriali
142142

143143
if (!type.TryGetBestMatchConstructor(out var constructor))
144144
{
145-
throw new TomlInstantiationException();
145+
throw new TomlInstantiationException(type);
146146
}
147147

148148
var parameters = constructor!.GetParameters();

0 commit comments

Comments
 (0)