1717package com .palantir .conjure .java .api .errors ;
1818
1919import com .palantir .logsafe .Arg ;
20+ import com .palantir .logsafe .SafeArg ;
2021import com .palantir .logsafe .SafeLoggable ;
2122import java .util .Collections ;
2223import java .util .List ;
2526public final class RemoteException extends RuntimeException implements SafeLoggable {
2627 private static final long serialVersionUID = 1L ;
2728
29+ private final String message ;
30+ private final String stableMessage ;
2831 private final SerializableError error ;
2932 private final int status ;
33+ private final List <Arg <?>> args ;
3034
3135 /** Returns the error thrown by a remote process which caused an RPC call to fail. */
3236 public SerializableError getError () {
@@ -39,27 +43,29 @@ public int getStatus() {
3943 }
4044
4145 public RemoteException (SerializableError error , int status ) {
42- super (
43- error .errorCode ().equals (error .errorName ())
44- ? String .format (
45- "RemoteException: %s with instance ID %s" , error .errorCode (), error .errorInstanceId ())
46- : String .format (
47- "RemoteException: %s (%s) with instance ID %s" ,
48- error .errorCode (), error .errorName (), error .errorInstanceId ()));
49-
46+ this .stableMessage = error .errorCode ().equals (error .errorName ())
47+ ? String .format ("RemoteException: %s" , error .errorCode ())
48+ : String .format ("RemoteException: %s (%s)" , error .errorCode (), error .errorName ());
49+ this .message = this .stableMessage + " with instance ID " + error .errorInstanceId ();
5050 this .error = error ;
5151 this .status = status ;
52+ this .args = Collections .singletonList (SafeArg .of ("errorInstanceId" , error .errorInstanceId ()));
53+ }
54+
55+ @ Override
56+ public String getMessage () {
57+ return message ;
5258 }
5359
5460 @ Override
5561 public String getLogMessage () {
56- return getMessage () ;
62+ return stableMessage ;
5763 }
5864
5965 @ Override
6066 public List <Arg <?>> getArgs () {
6167 // RemoteException explicitly does not support arguments because they have already been recorded
6268 // on the service which produced the causal SerializableError.
63- return Collections . emptyList () ;
69+ return args ;
6470 }
6571}
0 commit comments