@@ -53,7 +53,7 @@ public static <T> Response<T> newNotfound(String message, T value) {
5353 */
5454 public static <T > Response <T > fromListCheckedFailure (List <Object > response ,
5555 ResultFactory <T > resultFactory ) throws RemoteException {
56- StatusCode statusCode ;
56+ StatusCode statusCode = StatusCode . SUCCESS ;
5757 String message ;
5858 try {
5959 statusCode = StatusCode .fromInt ((Integer ) response .get (0 ));
@@ -63,13 +63,15 @@ public static <T> Response<T> fromListCheckedFailure(List<Object> response,
6363 }
6464
6565 } catch (ClassCastException e ) {
66- throw new RosRuntimeException (
67- "Remote side did not return correct type (status code/message)." , e );
66+ throw new RemoteException (StatusCode .FAILURE ,
67+ "Remote side did not return correct type headers in response. Expected StatusCode.class, got " +response .get (0 ).getClass ()+
68+ " and message of type String but got " +response .get (1 ).getClass ()+" for values " +response .get (0 )+" and " +response .get (1 ));
6869 }
6970 try {
7071 return new Response <T >(statusCode , message , resultFactory .newFromValue (response .get (2 )));
7172 } catch (ClassCastException e ) {
72- throw new RosRuntimeException ("Remote side did not return correct value type." , e );
73+ throw new RemoteException (StatusCode .FAILURE ,"Remote side did not return correct value type in response. Got " + response .get (2 ).getClass ()+
74+ " from value " + response .get (2 )+" expected " +((T )resultFactory ).getClass ());
7375 }
7476 }
7577
@@ -98,16 +100,18 @@ public static <T> Response<T> fromListChecked(List<Object> response,
98100 statusCode = StatusCode .fromInt ((Integer ) response .get (0 ));
99101 message = (String ) response .get (1 );
100102 if (statusCode != StatusCode .SUCCESS ) {
101-
102103 throw new RemoteException (statusCode , message );
103104 }
104105 } catch (ClassCastException e ) {
105- throw new RosRuntimeException ("Remote side did not return correct type (status code/message)." , e );
106+ throw new RemoteException (StatusCode .FAILURE ,
107+ "Remote side did not return correct type headers in response. Expected StatusCode.class, got " +response .get (0 ).getClass ()+
108+ " and message of type String but got " +response .get (1 ).getClass ()+" for values " +response .get (0 )+" and " +response .get (1 ));
106109 }
107110 try {
108111 return new Response <T >(statusCode , message , resultFactory .newFromValue (response .get (2 )));
109112 } catch (ClassCastException e ) {
110- throw new RosRuntimeException ("Remote side did not return correct value type." , e );
113+ throw new RemoteException (StatusCode .FAILURE ,"Remote side did not return correct value type in response. Got " + response .get (2 ).getClass ()+
114+ " from value " + response .get (2 )+" expected " +((T )resultFactory ).getClass ());
111115 }
112116 }
113117
@@ -142,12 +146,15 @@ public static <T> Response<T> fromListCheckedNotFound(List<Object> response,
142146 throw new RemoteException (statusCode , message );
143147 }
144148 } catch (ClassCastException e ) {
145- throw new RosRuntimeException ("Remote side did not return correct type (status code/message)." , e );
149+ throw new RemoteException (StatusCode .FAILURE ,
150+ "Remote side did not return correct type headers in response. Expected StatusCode.class, got " +response .get (0 ).getClass ()+
151+ " and message of type String but got " +response .get (1 ).getClass ()+" for values " +response .get (0 )+" and " +response .get (1 ));
146152 }
147153 try {
148154 return new Response <T >(statusCode , message , resultFactory .newFromValue (response .get (2 )));
149155 } catch (ClassCastException e ) {
150- throw new RosRuntimeException ("Remote side did not return correct value type." , e );
156+ throw new RemoteException (StatusCode .FAILURE ,"Remote side did not return correct value type in response. Got " + response .get (2 ).getClass ()+
157+ " from value " + response .get (2 )+" expected " +((T )resultFactory ).getClass ());
151158 }
152159 }
153160
0 commit comments