MCPcopy Index your code
hub / github.com/RustPython/RustPython / convert_socket_error

Function convert_socket_error

crates/stdlib/src/socket.rs:3325–3357  ·  view source on GitHub ↗
(
        vm: &VirtualMachine,
        err: dns_lookup::LookupError,
        err_kind: SocketError,
    )

Source from the content-addressed store, hash-verified

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())

Callers 5

getaddrinfoFunction · 0.85
gethostbyaddrFunction · 0.85
gethostbyname_exFunction · 0.85
getnameinfoFunction · 0.85
get_addrFunction · 0.85

Calls 7

gaierrorFunction · 0.85
herrorFunction · 0.85
to_strMethod · 0.80
new_os_subtype_errorMethod · 0.80
SomeClass · 0.50
kindMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected