@@ -72,6 +72,7 @@ impl fmt::Display for NewSessionError {
72
72
73
73
/// An error occurred while executing some browser action.
74
74
#[ derive( Debug ) ]
75
+ #[ non_exhaustive]
75
76
pub enum CmdError {
76
77
/// A standard WebDriver error occurred.
77
78
///
@@ -118,6 +119,9 @@ pub enum CmdError {
118
119
/// Could not decode a base64 image
119
120
ImageDecodeError ( base64:: DecodeError ) ,
120
121
122
+ /// Could not decode a base64 PDF.
123
+ PdfDecodeError ( base64:: DecodeError ) ,
124
+
121
125
/// Timeout of a wait condition.
122
126
///
123
127
/// When waiting for a for a condition using [`Client::wait`](crate::Client::wait), any of the
@@ -190,6 +194,7 @@ impl Error for CmdError {
190
194
CmdError :: NotW3C ( ..) => "webdriver returned non-conforming response" ,
191
195
CmdError :: InvalidArgument ( ..) => "invalid argument provided" ,
192
196
CmdError :: ImageDecodeError ( ..) => "error decoding image" ,
197
+ CmdError :: PdfDecodeError ( ..) => "error decoding PDF" ,
193
198
CmdError :: WaitTimeout => "timeout waiting on condition" ,
194
199
}
195
200
}
@@ -202,7 +207,7 @@ impl Error for CmdError {
202
207
CmdError :: FailedC ( ref e) => Some ( e) ,
203
208
CmdError :: Lost ( ref e) => Some ( e) ,
204
209
CmdError :: Json ( ref e) => Some ( e) ,
205
- CmdError :: ImageDecodeError ( ref e) => Some ( e) ,
210
+ CmdError :: ImageDecodeError ( ref e) | CmdError :: PdfDecodeError ( ref e ) => Some ( e) ,
206
211
CmdError :: NotJson ( _)
207
212
| CmdError :: NotW3C ( _)
208
213
| CmdError :: InvalidArgument ( ..)
@@ -224,7 +229,9 @@ impl fmt::Display for CmdError {
224
229
CmdError :: NotJson ( ref e) => write ! ( f, "{}" , e) ,
225
230
CmdError :: Json ( ref e) => write ! ( f, "{}" , e) ,
226
231
CmdError :: NotW3C ( ref e) => write ! ( f, "{:?}" , e) ,
227
- CmdError :: ImageDecodeError ( ref e) => write ! ( f, "{:?}" , e) ,
232
+ CmdError :: ImageDecodeError ( ref e) | CmdError :: PdfDecodeError ( ref e) => {
233
+ write ! ( f, "{:?}" , e)
234
+ }
228
235
CmdError :: InvalidArgument ( ref arg, ref msg) => {
229
236
write ! ( f, "Invalid argument `{}`: {}" , arg, msg)
230
237
}
@@ -285,6 +292,35 @@ impl From<InvalidWindowHandle> for CmdError {
285
292
}
286
293
}
287
294
295
+ /// Error of attempting to build an invalid [`PrintConfiguration`](crate::wd::PrintConfiguration).
296
+ #[ derive( Debug , PartialEq , Eq ) ]
297
+ #[ non_exhaustive]
298
+ pub enum PrintConfigurationError {
299
+ /// One or more dimensions of the page margins/size are negative.
300
+ NegativeDimensions ,
301
+ /// One or more dimensions of the page margins/size are NaN or infinite.
302
+ NonFiniteDimensions ,
303
+ /// The margins overflow the page size (e.g. margins.left + margins.right >= page.width).
304
+ DimensionsOverflow ,
305
+ /// Eighter one of print height or width are smaller than the [`PrintSize::MIN`](crate::wd::PrintSize::MIN).
306
+ PrintSizeTooSmall ,
307
+ }
308
+
309
+ impl fmt:: Display for PrintConfigurationError {
310
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
311
+ f. write_str ( match self {
312
+ Self :: NegativeDimensions => {
313
+ "one or more dimensions of the page (margins and/or size) are negative"
314
+ }
315
+ Self :: NonFiniteDimensions => {
316
+ "one or more dimensions of the page (margins and/or size) are NaN or infinite"
317
+ }
318
+ Self :: DimensionsOverflow => "the margins overflow the page size" ,
319
+ Self :: PrintSizeTooSmall => "the print size is too small" ,
320
+ } )
321
+ }
322
+ }
323
+
288
324
/// The error code returned from the WebDriver.
289
325
#[ derive( Debug , PartialEq , Eq , Hash ) ]
290
326
#[ non_exhaustive]
0 commit comments