File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 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)
8080 catch ( BencodeException ex )
8181 {
8282 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.",
8484 ex , startPosition ) ;
8585 }
8686
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+
8793 dictionary . Add ( key , value ) ;
8894 }
8995
@@ -96,6 +102,12 @@ public override BDictionary Parse(BencodeStream stream)
96102 return dictionary ;
97103 }
98104
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+
99111 private static InvalidBencodeException < BDictionary > InvalidException ( string message , Exception inner , long startPosition )
100112 {
101113 return new InvalidBencodeException < BDictionary > (
You can’t perform that action at this time.
0 commit comments