mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Add 'library', 'reason' Attribute to ssl.SSLError
This commit is contained in:
1 parent
aec155f050
commit
93d411d50a
1 file changed
+7
@@ -1150,10 +1150,17 @@ mod _ssl {
|
||||
// TODO: map the error codes to code names, e.g. "CERTIFICATE_VERIFY_FAILED", just requires a big hashmap/dict
|
||||
let errstr = e.reason().unwrap_or("unknown error");
|
||||
let msg = if let Some(lib) = e.library() {
|
||||
// add `library` attribute
|
||||
let attr_name = vm.ctx.as_ref().intern_str("library");
|
||||
cls.set_attr(attr_name, vm.ctx.new_str(lib).into());
|
||||
format!("[{}] {} ({}:{})", lib, errstr, file, line)
|
||||
} else {
|
||||
format!("{} ({}:{})", errstr, file, line)
|
||||
};
|
||||
// add `reason` attribute
|
||||
let attr_name = vm.ctx.as_ref().intern_str("reason");
|
||||
cls.set_attr(attr_name, vm.ctx.new_str(errstr).into());
|
||||
|
||||
let reason = sys::ERR_GET_REASON(e.code());
|
||||
vm.new_exception(
|
||||
cls,
|
||||
|
||||
Reference in new issue
Block a user