@SafeVarargs protected final List<Pair<String, String>> withBaseExceptionMessage( Throwable ex, Pair<String, String>... extraLogMessages ) { List<Pair<String, String>> logPairs = new ArrayList<>(); ApiExceptionHandlerUtils.DEFAULT_IMPL.addBaseExceptionMessageToExtraDetailsForLogging(ex, logPairs); if (extraLogMessages != null) { logPairs.addAll(Arrays.asList(extraLogMessages)); } return logPairs; }
protected final Pair<String, String> causeDetailsForLogs(Throwable orig) { Throwable cause = orig.getCause(); String causeDetails = (cause == null) ? "NO_CAUSE" : cause.toString(); return Pair.of("exception_cause_details", ApiExceptionHandlerUtils.DEFAULT_IMPL.quotesToApostrophes(causeDetails)); }
/** * @return All the headers in the given request as a comma-separated list of name=value in string form. * Multi-value headers will come back in name=[value1,value2] form. * NOTE: This method never throws an exception. If it catches one it will return blank string "" instead. */ public String parseRequestHeadersToString(RequestInfoForLogging request) { try { Map<String, List<String>> headers = request.getHeadersMap(); if (headers == null || headers.isEmpty()) return ""; Set<String> headerNames = headers.keySet(); StringBuilder sb = new StringBuilder(); boolean first = true; for (String headerName : headerNames) { if (!first) sb.append(","); sb.append(parseSpecificHeaderToString(request, headerName)); first = false; } return sb.toString(); } catch(Exception ex) { return ""; } }
String traceId = extractDistributedTraceId(request); String requestUri = request.getRequestUri(); String requestMethod = request.getRequestHttpMethod(); String queryString = request.getQueryString(); String headersString = parseRequestHeadersToString(request); String contributingErrorsString = concatenateErrorCollection(contributingErrors);
+ "details of the request along with the full stack trace of the original exception. " + "unfiltered_api_errors=%s", trackingLogKey, trackingUuid.toString(), utils.concatenateErrorCollection(clientErrors) )); filteredClientErrors = Collections.singletonList(genericServiceError); String errorId = utils.buildErrorMessageForLogs( logMessage, request, filteredClientErrors, highestPriorityStatusCode, coreException, extraDetailsForLogging );
errorUid = utils.buildErrorMessageForLogs( baseLogMessageBuilder, request, errorsToUse, httpStatusCodeToUse, ex, extraDetailsForLogging );
/** * Adds the given exception's {@link Exception#getMessage()} to the given extraDetailsForLogging with the key of * "exception_message" and with the exception's message pruned of quotes via {@link #quotesToApostrophes(String)}. */ public void addBaseExceptionMessageToExtraDetailsForLogging(Throwable ex, List<Pair<String, String>> extraDetailsForLogging) { extraDetailsForLogging.add(Pair.of("exception_message", quotesToApostrophes(ex.getMessage()))); }
utils.addBaseExceptionMessageToExtraDetailsForLogging(ex, extraDetailsForLogging); WebApplicationException webex = (WebApplicationException) ex; Response webExResponse = webex.getResponse(); utils.addBaseExceptionMessageToExtraDetailsForLogging(ex, extraDetailsForLogging); handledErrors = singletonSortedSetOf(projectApiErrors.getMalformedRequestApiError());
Pair.of("serverside_validation_errors", utils.quotesToApostrophes(sb.toString())) );
.append("|").append(violation.getMessage()); extraDetailsForLogging.add(Pair.of("constraint_violation_details", utils.quotesToApostrophes(sb.toString())));