// Token: 0x060012C5 RID: 4805 RVA: 0x0003CCCC File Offset: 0x0003AECC private static PswsErrorCode TranslateErrorCode(PswsErrorCode orginalErrorCode, Exception exception, string additionalInfo) { if (orginalErrorCode == PswsErrorCode.CmdletExecutionFailure) { foreach (KeyValuePair <PswsErrorCode, Type[]> keyValuePair in PswsErrorHandling.ExceptionErrorCodeMapping) { foreach (Type type in keyValuePair.Value) { if (type.IsInstanceOfType(exception)) { return(keyValuePair.Key); } } } return(orginalErrorCode); } return(orginalErrorCode); }
// Token: 0x060012C4 RID: 4804 RVA: 0x0003CB88 File Offset: 0x0003AD88 internal static void SendErrorToClient(PswsErrorCode errorCode, Exception exception, string additionalInfo) { ExTraceGlobals.PublicPluginAPITracer.TraceDebug <PswsErrorCode, Exception, string>(0L, "[PswsErrorHandling.SendErrorToClient] Error Code = {0}, Exception = \"{1}\", additionalInfo = \"{2}\".", errorCode, exception, additionalInfo); try { HttpContext httpContext = HttpContext.Current; if (httpContext != null) { HttpResponse response = httpContext.Response; if (response != null) { if (response.Headers["X-Psws-ErrorCode"] == null) { response.AddHeader("X-Psws-ErrorCode", ((int)PswsErrorHandling.TranslateErrorCode(errorCode, exception, additionalInfo)).ToString()); HttpLogger.SafeSetLogger(ServiceCommonMetadata.ErrorCode, errorCode); if (exception != null) { string text = exception.GetType() + "," + exception.Message; if (text.Length > 500) { text = text.Substring(0, 500 - "...(truncated)".Length); text += "...(truncated)"; } response.AddHeader("X-Psws-Exception", text); HttpLogger.SafeAppendGenericInfo("PswsExceptionInfo", text); } if (!string.IsNullOrWhiteSpace(additionalInfo)) { response.AddHeader("X-Psws-ErrorInfo", additionalInfo); HttpLogger.SafeAppendGenericInfo("PswsErrorAdditionalInfo", additionalInfo); } } } } } catch (Exception ex) { ExTraceGlobals.PublicPluginAPITracer.TraceDebug <Exception>(0L, "[PswsErrorHandling.SendErrorToClient] Exception {0}.", ex); HttpLogger.SafeAppendGenericError("SendErrorToClientError", ex, new Func <Exception, bool>(KnownException.IsUnhandledException)); } }