@@ -983,10 +983,12 @@ def __init__(
983983 _empty_init = False ,
984984 _levels = - 3 ,
985985 ):
986- self ._g = error_code_group
987- if success and isinstance (value , ResultErr ):
986+ if isinstance (value , ResultErr ):
988987 success = False
989988 self ._g = value ._g
989+ else :
990+ self ._g = error_code_group
991+
990992 if _empty_init :
991993 self ._success = None
992994 self ._Ok = ""
@@ -1369,14 +1371,14 @@ def __getattr__(self, name):
13691371 def method (* args , ** kwargs ):
13701372 try :
13711373 res = attr (* args , ** kwargs )
1372- return Result (res ) if res is not None else None
1374+ return Result (res , error_code_group = self . _g ) # if res is not None else None
13731375 except Exception as e :
13741376 return Result .Err (f"VAR.{ name } () raises { e } " , self .error_code ("Method" ), self ._g )
13751377
13761378 return method
13771379 if isinstance (attr , Result ):
13781380 return attr
1379- return Result (attr )
1381+ return Result (attr , error_code_group = self . _g )
13801382 except AttributeError :
13811383 self .add_Err_msg (f"VAR.{ name } raises an AttributeError" , self .error_code ("Attribute" ))
13821384 return self
@@ -1402,7 +1404,7 @@ def __add__(self, other): # add operation, a + b
14021404 if errored :
14031405 return other
14041406 try :
1405- return Result (self ._Ok + other )
1407+ return Result (self ._Ok + other , error_code_group = self . _g )
14061408 except Exception as e :
14071409 return self ._operator_overload_error (e , op , False )
14081410
@@ -1412,7 +1414,7 @@ def __radd__(self, other): # reflective add operation, b + a
14121414 if errored :
14131415 return other
14141416 try :
1415- return Result (other + self ._Ok )
1417+ return Result (other + self ._Ok , error_code_group = self . _g )
14161418 except Exception as e :
14171419 return self ._operator_overload_error (e , op , False )
14181420
@@ -1434,7 +1436,7 @@ def __sub__(self, other): # subtraction operation, a - b
14341436 if errored :
14351437 return other
14361438 try :
1437- return Result (self ._Ok - other )
1439+ return Result (self ._Ok - other , error_code_group = self . _g )
14381440 except Exception as e :
14391441 return self ._operator_overload_error (e , op , False )
14401442
@@ -1444,7 +1446,7 @@ def __rsub__(self, other): # reflective subtraction operation, b - a
14441446 if errored :
14451447 return other
14461448 try :
1447- return Result (other - self ._Ok )
1449+ return Result (other - self ._Ok , error_code_group = self . _g )
14481450 except Exception as e :
14491451 return self ._operator_overload_error (e , op , False )
14501452
@@ -1466,7 +1468,7 @@ def __mul__(self, other): # multiplication operation, a * b
14661468 if errored :
14671469 return other
14681470 try :
1469- return Result (self ._Ok * other )
1471+ return Result (self ._Ok * other , error_code_group = self . _g )
14701472 except Exception as e :
14711473 return self ._operator_overload_error (e , op , False )
14721474
@@ -1476,7 +1478,7 @@ def __rmul__(self, other): # reflective multiplication operation, b * a
14761478 if errored :
14771479 return other
14781480 try :
1479- return Result (other * self ._Ok )
1481+ return Result (other * self ._Ok , error_code_group = self . _g )
14801482 except Exception as e :
14811483 return self ._operator_overload_error (e , op , False )
14821484
@@ -1498,7 +1500,7 @@ def __truediv__(self, other): # division operation, a / b
14981500 if errored :
14991501 return other
15001502 try :
1501- return Result (self ._Ok / other )
1503+ return Result (self ._Ok / other , error_code_group = self . _g )
15021504 except Exception as e :
15031505 return self ._operator_overload_error (e , op , False )
15041506
@@ -1508,7 +1510,7 @@ def __rtruediv__(self, other): # reflective division operation, b / a
15081510 if errored :
15091511 return other
15101512 try :
1511- return Result (other / self ._Ok )
1513+ return Result (other / self ._Ok , error_code_group = self . _g )
15121514 except Exception as e :
15131515 return self ._operator_overload_error (e , op , False )
15141516
@@ -1530,7 +1532,7 @@ def __floordiv__(self, other): # floor division operation, a // b
15301532 if errored :
15311533 return other
15321534 try :
1533- return Result (self ._Ok // other )
1535+ return Result (self ._Ok // other , error_code_group = self . _g )
15341536 except Exception as e :
15351537 return self ._operator_overload_error (e , op , False )
15361538
@@ -1540,7 +1542,7 @@ def __rfloordiv__(self, other): # reflective floor division operation, b // a
15401542 if errored :
15411543 return other
15421544 try :
1543- return Result (other // self ._Ok )
1545+ return Result (other // self ._Ok , error_code_group = self . _g )
15441546 except Exception as e :
15451547 return self ._operator_overload_error (e , op , False )
15461548
@@ -1562,7 +1564,7 @@ def __mod__(self, other): # modulus operation, a % b
15621564 if errored :
15631565 return other
15641566 try :
1565- return Result (self ._Ok % other )
1567+ return Result (self ._Ok % other , error_code_group = self . _g )
15661568 except Exception as e :
15671569 return self ._operator_overload_error (e , op , False )
15681570
@@ -1572,7 +1574,7 @@ def __rmod__(self, other): # reflective modulus operation, b % a
15721574 if errored :
15731575 return other
15741576 try :
1575- return Result (other % self ._Ok )
1577+ return Result (other % self ._Ok , error_code_group = self . _g )
15761578 except Exception as e :
15771579 return self ._operator_overload_error (e , op , False )
15781580
@@ -1594,7 +1596,7 @@ def __pow__(self, other): # exponentiation operation, a ** b
15941596 if errored :
15951597 return other
15961598 try :
1597- return Result (self ._Ok ** other )
1599+ return Result (self ._Ok ** other , error_code_group = self . _g )
15981600 except Exception as e :
15991601 return self ._operator_overload_error (e , op , False )
16001602
@@ -1604,15 +1606,15 @@ def __rpow__(self, other): # reflective exponentiation operation, b ** a
16041606 if errored :
16051607 return other
16061608 try :
1607- return Result (other ** self ._Ok )
1609+ return Result (other ** self ._Ok , error_code_group = self . _g )
16081610 except Exception as e :
16091611 return self ._operator_overload_error (e , op , False )
16101612
16111613 def __int__ (self ): # To get called by built-in int() method to convert a type to an int.
16121614 self ._empty_error ()
16131615 if self ._success :
16141616 try :
1615- return Result (int (self ._Ok ))
1617+ return Result (int (self ._Ok ), error_code_group = self . _g )
16161618 except Exception as e :
16171619 self .add_Err_msg ("Result(int(a)) resulted in an Exception." )
16181620 self .add_Err_msg (f"{ type (e ).__name__ } : { e } " , self .error_code ("Int_Op" ), add_traceback = False )
@@ -1624,7 +1626,7 @@ def __float__(self): # To get called by built-in float() method to convert a ty
16241626 self ._empty_error ()
16251627 if self ._success :
16261628 try :
1627- return Result (float (self ._Ok ))
1629+ return Result (float (self ._Ok ), error_code_group = self . _g )
16281630 except Exception as e :
16291631 self .add_Err_msg ("Result(float(a)) resulted in an Exception." )
16301632 self .add_Err_msg (f"{ type (e ).__name__ } : { e } " , self .error_code ("Float_Op" ), add_traceback = False )
0 commit comments