@@ -51,7 +51,7 @@ public HtmlConversionBehaviorBuilder SetBrowserWaitExpression(string expression)
5151 {
5252 if ( expression . IsNotSet ( ) )
5353 {
54- throw new InvalidOperationException ( "expression is not set" ) ;
54+ throw new ArgumentException ( "expression cannot be null or empty" , nameof ( expression ) ) ;
5555 }
5656
5757 _htmlConversionBehaviors . WaitForExpression = expression ;
@@ -70,7 +70,7 @@ public HtmlConversionBehaviorBuilder SetUserAgent(string userAgent)
7070 {
7171 if ( userAgent . IsNotSet ( ) )
7272 {
73- throw new InvalidOperationException ( "headerName is not set" ) ;
73+ throw new ArgumentException ( "userAgent cannot be null or empty" , nameof ( userAgent ) ) ;
7474 }
7575
7676 _htmlConversionBehaviors . UserAgent = userAgent ;
@@ -103,7 +103,7 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(JObject extraHeaders)
103103 {
104104 if ( extraHeaders == null )
105105 {
106- throw new InvalidOperationException ( " extraHeaders is null" ) ;
106+ throw new ArgumentNullException ( nameof ( extraHeaders ) ) ;
107107 }
108108
109109 _htmlConversionBehaviors . ExtraHeaders = extraHeaders ;
@@ -142,6 +142,11 @@ public HtmlConversionBehaviorBuilder AddCookie(Cookie cookie)
142142 /// <returns></returns>
143143 public HtmlConversionBehaviorBuilder SetMetadata ( IDictionary < string , object > dictionary )
144144 {
145+ if ( dictionary == null )
146+ {
147+ throw new ArgumentNullException ( nameof ( dictionary ) ) ;
148+ }
149+
145150 SetMetadata ( JObject . FromObject ( dictionary ) ) ;
146151
147152 return this ;
@@ -158,7 +163,7 @@ public HtmlConversionBehaviorBuilder SetMetadata(JObject metadata)
158163 {
159164 if ( metadata == null )
160165 {
161- throw new InvalidOperationException ( " metadata is null" ) ;
166+ throw new ArgumentNullException ( nameof ( metadata ) ) ;
162167 }
163168
164169 _htmlConversionBehaviors . MetaData = metadata ;
@@ -209,7 +214,7 @@ public HtmlConversionBehaviorBuilder SetPdfFormat(ConversionPdfFormats format)
209214 {
210215 if ( format == default )
211216 {
212- throw new InvalidOperationException ( "Invalid PDF format specified" ) ;
217+ throw new ArgumentOutOfRangeException ( nameof ( format ) , "Invalid PDF format specified" ) ;
213218 }
214219
215220 _htmlConversionBehaviors . PdfFormat = format ;
0 commit comments