|
1 | 1 | /******************************************************************************* |
2 | | -* Copyright (c) 2017-2021 Microsoft Corporation and others. |
| 2 | +* Copyright (c) 2017-2020 Microsoft Corporation and others. |
3 | 3 | * All rights reserved. This program and the accompanying materials |
4 | 4 | * are made available under the terms of the Eclipse Public License v1.0 |
5 | 5 | * which accompanies this distribution, and is available at |
|
14 | 14 | import java.util.Arrays; |
15 | 15 | import java.util.List; |
16 | 16 | import java.util.Map; |
| 17 | +import java.util.concurrent.CancellationException; |
17 | 18 | import java.util.concurrent.CompletableFuture; |
18 | 19 | import java.util.concurrent.CompletionException; |
19 | 20 | import java.util.concurrent.ExecutionException; |
@@ -105,58 +106,31 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments, |
105 | 106 | indexedVariables = ((IntegerValue) sizeValue).value(); |
106 | 107 | } |
107 | 108 | } |
108 | | - } catch (Exception e) { |
109 | | - logger.log(Level.INFO, "Failed to get the logical size of the variable", e); |
| 109 | + } catch (CancellationException | IllegalArgumentException | InterruptedException |
| 110 | + | ExecutionException | UnsupportedOperationException e) { |
| 111 | + logger.log(Level.INFO, |
| 112 | + String.format("Failed to get the logical size for the type %s.", value.type().name()), e); |
110 | 113 | } |
111 | 114 | } |
112 | 115 | int referenceId = 0; |
113 | 116 | if (indexedVariables > 0 || (indexedVariables < 0 && value instanceof ObjectReference)) { |
114 | 117 | referenceId = context.getRecyclableIdPool().addObject(threadId, varProxy); |
115 | 118 | } |
116 | 119 |
|
117 | | - boolean hasErrors = false; |
118 | | - String valueString = null; |
119 | | - try { |
120 | | - valueString = variableFormatter.valueToString(value, options); |
121 | | - } catch (OutOfMemoryError e) { |
122 | | - hasErrors = true; |
123 | | - logger.log(Level.SEVERE, "Failed to convert the value of a large object to a string", e); |
124 | | - valueString = "<Unable to display the value of a large object>"; |
125 | | - } catch (Exception e) { |
126 | | - hasErrors = true; |
127 | | - logger.log(Level.SEVERE, "Failed to resolve the variable value", e); |
128 | | - valueString = "<Failed to resolve the variable value due to \"" + e.getMessage() + "\">"; |
129 | | - } |
130 | | - |
| 120 | + String valueString = variableFormatter.valueToString(value, options); |
131 | 121 | String detailsString = null; |
132 | | - if (hasErrors) { |
133 | | - // If failed to resolve the variable value, skip the details info as well. |
134 | | - } else if (sizeValue != null) { |
| 122 | + if (sizeValue != null) { |
135 | 123 | detailsString = "size=" + variableFormatter.valueToString(sizeValue, options); |
136 | 124 | } else if (DebugSettings.getCurrent().showToString) { |
137 | | - try { |
138 | | - detailsString = VariableDetailUtils.formatDetailsValue(value, stackFrameReference.getThread(), variableFormatter, options, engine); |
139 | | - } catch (OutOfMemoryError e) { |
140 | | - logger.log(Level.SEVERE, "Failed to compute the toString() value of a large object", e); |
141 | | - detailsString = "<Unable to display the details of a large object>"; |
142 | | - } catch (Exception e) { |
143 | | - logger.log(Level.SEVERE, "Failed to compute the toString() value", e); |
144 | | - detailsString = "<Failed to resolve the variable details due to \"" + e.getMessage() + "\">"; |
145 | | - } |
| 125 | + detailsString = VariableDetailUtils.formatDetailsValue(value, stackFrameReference.getThread(), variableFormatter, options, engine); |
146 | 126 | } |
147 | 127 |
|
148 | 128 | if ("clipboard".equals(evalArguments.context) && detailsString != null) { |
149 | 129 | response.body = new Responses.EvaluateResponseBody(detailsString, -1, "String", 0); |
150 | 130 | } else { |
151 | | - String typeString = ""; |
152 | | - try { |
153 | | - typeString = variableFormatter.typeToString(value == null ? null : value.type(), options); |
154 | | - } catch (Exception e) { |
155 | | - logger.log(Level.SEVERE, "Failed to resolve the variable type", e); |
156 | | - typeString = ""; |
157 | | - } |
158 | 131 | response.body = new Responses.EvaluateResponseBody((detailsString == null) ? valueString : valueString + " " + detailsString, |
159 | | - referenceId, typeString, Math.max(indexedVariables, 0)); |
| 132 | + referenceId, variableFormatter.typeToString(value == null ? null : value.type(), options), |
| 133 | + Math.max(indexedVariables, 0)); |
160 | 134 | } |
161 | 135 | return response; |
162 | 136 | } |
|
0 commit comments