Skip to content

Commit 2599121

Browse files
committed
Move exception reporting to debugtool
1 parent d8c09da commit 2599121

9 files changed

Lines changed: 23 additions & 25 deletions

File tree

base/src/main/java/com/smartdevicelink/exception/SdlException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public String toString() {
7171
}
7272
if (detail != null) {
7373
ret += "\nnested: " + detail.toString();
74-
detail.printStackTrace();
7574
}
7675
return ret;
7776
}

base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void onResponse(int correlationId, RPCResponse response) {
205205
try {
206206
DebugTool.logInfo(TAG, response.serializeJSON().toString());
207207
} catch (JSONException e) {
208-
e.printStackTrace();
208+
DebugTool.logError(TAG, "Error attempting to serialize ChangeRegistrationResponse", e);
209209
}
210210

211211
// go through and change sdlManager properties that were changed via the LCU update

base/src/main/java/com/smartdevicelink/managers/file/UploadFileOperation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.smartdevicelink.proxy.rpc.PutFile;
4444
import com.smartdevicelink.proxy.rpc.PutFileResponse;
4545
import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
46+
import com.smartdevicelink.util.DebugTool;
4647

4748
import java.io.IOException;
4849
import java.io.InputStream;
@@ -221,7 +222,7 @@ private void closeInputStream() {
221222
try {
222223
this.inputStream.close();
223224
} catch (IOException e) {
224-
e.printStackTrace();
225+
DebugTool.logError(TAG,"Error attempting to close input stream", e);
225226
}
226227
}
227228

@@ -330,7 +331,7 @@ private byte[] getDataChunkWithSize(int size, InputStream inputStream) {
330331
try {
331332
bytesRead = inputStream.read(buffer, 0, size);
332333
} catch (IOException e) {
333-
e.printStackTrace();
334+
DebugTool.logError(TAG,"Error attempting to read from input stream", e);
334335
}
335336

336337
if (bytesRead > 0) {
@@ -365,7 +366,7 @@ private int getFileSizeFromInputStream(InputStream inputStream) {
365366
try {
366367
size = inputStream.available();
367368
} catch (IOException e) {
368-
e.printStackTrace();
369+
DebugTool.logError(TAG,"Error trying to get input stream size", e);
369370
}
370371
}
371372
return size;

base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void start() {
146146
try {
147147
session.startSession();
148148
} catch (SdlException e) {
149-
e.printStackTrace();
149+
DebugTool.logError(TAG,"Error attempting to start session", e);
150150
}
151151
}
152152

@@ -851,7 +851,7 @@ private void sendRPCMessagePrivate(RPCMessage message, boolean isInternalMessage
851851
session.sendMessage(pm);
852852

853853
} catch (OutOfMemoryError e) {
854-
e.printStackTrace();
854+
DebugTool.logError(TAG,"Error attempting to send RPC message.", e);
855855
}
856856
}
857857

base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ public void onResponse(int correlationId, RPCResponse response) {
12751275
try {
12761276
DebugTool.logInfo(TAG, "Main Menu response: " + response.serializeJSON().toString());
12771277
} catch (JSONException e) {
1278-
e.printStackTrace();
1278+
DebugTool.logError(TAG,"Error attempting to serialize JSON of RPC response", e);
12791279
}
12801280
} else {
12811281
DebugTool.logError(TAG, "Result: " + response.getResultCode() + " Info: " + response.getInfo());
@@ -1313,7 +1313,7 @@ public void onResponse(int correlationId, RPCResponse response) {
13131313
try {
13141314
DebugTool.logInfo(TAG, "Sub Menu response: " + response.serializeJSON().toString());
13151315
} catch (JSONException e) {
1316-
e.printStackTrace();
1316+
DebugTool.logError(TAG,"Error attempting to serialize JSON of RPC response", e);
13171317
}
13181318
} else {
13191319
DebugTool.logError(TAG, "Failed to send sub menu commands: " + response.getInfo());
@@ -1365,7 +1365,7 @@ public void onResponse(int correlationId, RPCResponse response) {
13651365
try {
13661366
DebugTool.logInfo(TAG, "Dynamic Sub Menu response: " + response.serializeJSON().toString());
13671367
} catch (JSONException e) {
1368-
e.printStackTrace();
1368+
DebugTool.logError(TAG,"Error attempting to serialize JSON of RPC response", e);
13691369
}
13701370
} else {
13711371
DebugTool.logError(TAG, "Result: " + response.getResultCode() + " Info: " + response.getInfo());

base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import java.util.Set;
5151

5252
public class RPCStruct implements Cloneable {
53+
private static final String TAG = "RPCStruct";
54+
5355
public static final String KEY_BULK_DATA = "bulkData";
5456
public static final String KEY_PROTECTED = "protected";
5557

@@ -268,7 +270,7 @@ protected Object formatObject(Class tClass, Object obj) {
268270

269271
return customObject;
270272
} catch (Exception e) {
271-
e.printStackTrace();
273+
DebugTool.logError(TAG,"Error attempting to format an object from a Hashtable", e);
272274
}
273275
} else if (obj instanceof List<?>) {
274276
List<?> list = (List<?>) obj;
@@ -300,7 +302,7 @@ protected Object formatObject(Class tClass, Object obj) {
300302
}
301303
newList.add(customObject);
302304
} catch (Exception e) {
303-
e.printStackTrace();
305+
DebugTool.logError(TAG,"Error attempting to format object from list of Hashtables", e);
304306
return null;
305307
}
306308
}
@@ -334,15 +336,15 @@ protected Object getValueForString(Class tClass, String s) {
334336
try {
335337
valueForString = tClass.getDeclaredMethod("valueForString", String.class);
336338
} catch (NoSuchMethodException e) {
337-
e.printStackTrace();
339+
DebugTool.logError(TAG,"Error attempting to find valueForString method in class", e);
338340
}
339341
if (valueForString != null) {
340342
try {
341343
return valueForString.invoke(null, (String) s);
342344
} catch (IllegalAccessException e) {
343-
e.printStackTrace();
345+
DebugTool.logError(TAG,"Illegal access while using reflection to get enum from string", e);
344346
} catch (InvocationTargetException e) {
345-
e.printStackTrace();
347+
DebugTool.logError(TAG,"Error attempting to use method from reflection to get enum from string", e);
346348
}
347349
}
348350
return null;

base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,9 @@ private void handleBulkData(byte[] bulkData) {
179179
tempBody = getBody(httpJson);
180180
tempHeaders = getHeaders(httpJson);
181181
} catch (JSONException e) {
182-
DebugTool.logError(TAG, "HTTPRequest in bulk data was malformed.");
183-
e.printStackTrace();
182+
DebugTool.logError(TAG, "HTTPRequest in bulk data was malformed.", e);
184183
} catch (NullPointerException e) {
185-
DebugTool.logError(TAG, "Invalid HTTPRequest object in bulk data.");
186-
e.printStackTrace();
184+
DebugTool.logError(TAG, "Invalid HTTPRequest object in bulk data.", e);
187185
}
188186
} else if (RequestType.HTTP.equals(this.getRequestType())) {
189187
tempHeaders = new Headers();
@@ -209,8 +207,7 @@ private String getBody(JSONObject httpJson) {
209207
try {
210208
result = httpJson.getString(KEY_BODY);
211209
} catch (JSONException e) {
212-
DebugTool.logError(TAG, KEY_BODY + " key doesn't exist in bulk data.");
213-
e.printStackTrace();
210+
DebugTool.logError(TAG, KEY_BODY + " key doesn't exist in bulk data.", e);
214211
}
215212

216213
return result;
@@ -224,8 +221,7 @@ private Headers getHeaders(JSONObject httpJson) {
224221
Hashtable<String, Object> httpHeadersHash = JsonRPCMarshaller.deserializeJSONObject(httpHeadersJson);
225222
result = new Headers(httpHeadersHash);
226223
} catch (JSONException e) {
227-
DebugTool.logError(TAG, KEY_HEADERS + " key doesn't exist in bulk data.");
228-
e.printStackTrace();
224+
DebugTool.logError(TAG, KEY_HEADERS + " key doesn't exist in bulk data.", e);
229225
}
230226

231227
return result;

base/src/main/java/com/smartdevicelink/transport/SiphonServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static short disableSiphonServer() {
107107
try {
108108
SiphonServer.closeServer();
109109
} catch (IOException e) {
110-
e.printStackTrace();
110+
DebugTool.logError(TAG,"Error while trying to close siphon server", e);
111111
}
112112

113113
return m_listenPort;

base/src/main/java/com/smartdevicelink/util/FileUtls.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static byte[] getFileData(String filePath, String fileName) {
7474
try {
7575
return Files.readAllBytes(file.toPath());
7676
} catch (IOException e) {
77-
e.printStackTrace();
77+
DebugTool.logError(TAG,"Error trying to get file data", e);
7878
}
7979
}
8080
}

0 commit comments

Comments
 (0)