File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,16 @@ public override BDictionary Parse(BencodeStream stream)
80
80
catch ( BencodeException ex )
81
81
{
82
82
throw InvalidException (
83
- "Could not parse dictionary value. There needs to be a value for each key." ,
83
+ $ "Could not parse dictionary value for the key ' { key } ' . There needs to be a value for each key.",
84
84
ex , startPosition ) ;
85
85
}
86
86
87
+ if ( dictionary . ContainsKey ( key ) )
88
+ {
89
+ throw InvalidException (
90
+ $ "The dictionary already contains the key '{ key } '. Duplicate keys are not supported.", startPosition ) ;
91
+ }
92
+
87
93
dictionary . Add ( key , value ) ;
88
94
}
89
95
@@ -96,6 +102,12 @@ public override BDictionary Parse(BencodeStream stream)
96
102
return dictionary ;
97
103
}
98
104
105
+ private static InvalidBencodeException < BDictionary > InvalidException ( string message , long startPosition )
106
+ {
107
+ return new InvalidBencodeException < BDictionary > (
108
+ $ "{ message } The dictionary starts at position { startPosition } .", startPosition ) ;
109
+ }
110
+
99
111
private static InvalidBencodeException < BDictionary > InvalidException ( string message , Exception inner , long startPosition )
100
112
{
101
113
return new InvalidBencodeException < BDictionary > (
You can’t perform that action at this time.
0 commit comments