(
vm: &VirtualMachine,
err: dns_lookup::LookupError,
err_kind: SocketError,
)
| 3323 | }; |
| 3324 | |
| 3325 | fn convert_socket_error( |
| 3326 | vm: &VirtualMachine, |
| 3327 | err: dns_lookup::LookupError, |
| 3328 | err_kind: SocketError, |
| 3329 | ) -> IoOrPyException { |
| 3330 | if let dns_lookup::LookupErrorKind::System = err.kind() { |
| 3331 | return io::Error::from(err).into(); |
| 3332 | } |
| 3333 | let strerr = { |
| 3334 | #[cfg(unix)] |
| 3335 | { |
| 3336 | let s = match err_kind { |
| 3337 | SocketError::GaiError => unsafe { |
| 3338 | ffi::CStr::from_ptr(libc::gai_strerror(err.error_num())) |
| 3339 | }, |
| 3340 | SocketError::HError => unsafe { |
| 3341 | ffi::CStr::from_ptr(libc::hstrerror(err.error_num())) |
| 3342 | }, |
| 3343 | }; |
| 3344 | s.to_str().unwrap() |
| 3345 | } |
| 3346 | #[cfg(windows)] |
| 3347 | { |
| 3348 | "getaddrinfo failed" |
| 3349 | } |
| 3350 | }; |
| 3351 | let exception_cls = match err_kind { |
| 3352 | SocketError::GaiError => gaierror(vm), |
| 3353 | SocketError::HError => herror(vm), |
| 3354 | }; |
| 3355 | vm.new_os_subtype_error(exception_cls, Some(err.error_num()), strerr) |
| 3356 | .into() |
| 3357 | } |
| 3358 | |
| 3359 | fn timeout_error(vm: &VirtualMachine) -> PyRef<PyOSError> { |
| 3360 | timeout_error_msg(vm, "timed out".to_owned()) |
no test coverage detected