@@ -127,3 +127,28 @@ func TestGetErrorDetails_TimeoutError(t *testing.T) {
127127 require .Equal (t , fmt .Sprintf ("%v %v" , errReasonTimeout , s .TimeoutTypeHeartbeat ), reason )
128128 require .Equal (t , val2 , data )
129129}
130+
131+ func TestConstructError_TimeoutError (t * testing.T ) {
132+ dc := getDefaultDataConverter ()
133+ details , err := dc .ToData (testErrorDetails1 )
134+ require .NoError (t , err )
135+
136+ reason := fmt .Sprintf ("%v %v" , errReasonTimeout , s .TimeoutTypeHeartbeat )
137+ constructedErr := constructError (reason , details , dc )
138+ timeoutErr , ok := constructedErr .(* TimeoutError )
139+ require .True (t , ok )
140+ require .True (t , timeoutErr .HasDetails ())
141+ var detailValue string
142+ err = timeoutErr .Details (& detailValue )
143+ require .NoError (t , err )
144+ require .Equal (t , testErrorDetails1 , detailValue )
145+
146+ // Backward compatibility test
147+ reason = errReasonTimeout
148+ details , err = dc .ToData (s .TimeoutTypeHeartbeat )
149+ constructedErr = constructError (reason , details , dc )
150+ timeoutErr , ok = constructedErr .(* TimeoutError )
151+ require .True (t , ok )
152+ require .Equal (t , s .TimeoutTypeHeartbeat , timeoutErr .TimeoutType ())
153+ require .False (t , timeoutErr .HasDetails ())
154+ }
0 commit comments