Skip to content

Commit fbd1253

Browse files
committed
clearer error when forgeting to provide a value for a placeholder
1 parent e02c69e commit fbd1253

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/ConvNetSharp.Flow/Session.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ public void UpdatePlaceHolder(Op<T> fun, Dictionary<string, Volume<T>> dictionar
126126
{
127127
if (op is PlaceHolder<T> placeHolder)
128128
{
129-
placeHolder.SetValue(dictionary[placeHolder.Name]);
129+
if (!dictionary.TryGetValue(placeHolder.Name, out var volume))
130+
{
131+
throw new Exception($"Cannot find key '{placeHolder.Name}' in the provided dictionary");
132+
}
133+
134+
placeHolder.SetValue(volume);
130135
}
131136

132137
if (op is Variable<T> variable && variable.IsLearnable)

0 commit comments

Comments
 (0)