我在调试模式下运行代码,并意识到路径error.exception.cause.errorMessage.typedValue.value中出现以下错误消息。
{
"error": "authentication failed: Could not bind with your username/pw: LDAP Result Code 49 \"Invalid Credentials\": 80090308: LdapErr: DSID-0C090442, comment: AcceptSecurityContext error, data 52e, v3839\u0000"
}
但是当我尝试获取值时
(read(error.exception.cause.errorMessage.typedValue.value,"application/json"))
在抛出低于错误的变量中。
ERROR 2020-05-28 08:43:56,779 [[MuleRuntime].io.01: [proc-brain-usage-sync-batch].send-usage-data-to-brain.BLOCKING @164a6d7b] [event: 2ec6d1e1-a049-11ea-9b85-00059a3c7a00] org.mule.extension.jsonlogger.JsonLoggerExtension: Failed parsing field: content
org.mule.runtime.core.api.expression.ExpressionRuntimeException: "You called the function 'Value Selector' with these arguments:
1: String ("{\"error\":\"authentication failed: Could not bind with your username/pw: LD...)
2: Name ("value")
But it expects one of these combinations:
(Array, Name)
(Array, String)
(Date, Name)
(DateTime, Name)
(LocalDateTime, Name)
(LocalTime, Name)
(Object, Name)
(Object, String)
(Period, Name)
(Time, Name)
5| brainerror: write(error.exception.cause.errorMessage.typedValue.value, "application/json") default ""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Trace:
at write (line: 5, column: 20)
at main (line: 5, column: 14)" evaluating expression: "output application/json ---
{
usageMetadata: vars.usageMetadata,
attributes: attributes,
brainerror: write(error.exception.cause.errorMessage.typedValue.value, "application/json") default ""
}".
Caused by: org.mule.runtime.api.el.ExpressionExecutionException: You called the function 'Value Selector' with these arguments:
1: String ("{\"error\":\"authentication failed: Could not bind with your username/pw: LD...)
2: Name ("value")
But it expects one of these combinations:
(Array, Name)
(Array, String)
(Date, Name)
(DateTime, Name)
(LocalDateTime, Name)
(LocalTime, Name)
(Object, Name)
(Object, String)
(Period, Name)
(Time, Name)
5| brainerror: write(error.exception.cause.errorMessage.typedValue.value, "application/json") default ""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我如何捕获错误.description的方式捕获路径'error.exception.cause.errorMessage.typedValue.value'中的值?
您的error.exception.cause.errorMessage.typedValue.value是字符串,您尝试将其转换为JSON以进行写入。不要转换-照原样写(已经是字符串)。
换句话说-不要使用write-字符串已经是字符串。
或者,也许您需要相反的东西?要将String更改为JSON?这是更常见的需求,由读取功能完成。 https://simpleflatservice.com/mule4/ChangeStringToJsonOnTheFly.html