You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-24Lines changed: 54 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,9 @@ This custom error handler plugin allows a single module to process error message
18
18
- No specific error type is required for this module. It can parse any error types.
19
19
- Propagate errors from sys/prc layer back to exp layer, cementing error propagation across layers.
20
20
- To propagate the errors, ensure the appropriate variable name is referenced in the previous error section.
21
+
- Support for Mule error components to be factored into the error message based on boolean fields.
22
+
- Using Mule Error components will give very prescriptive error messages.
23
+
- Support for debug log package: `org.mulesoft.modules.errorhandler`
21
24
22
25
## Operations Supported
23
26
On Error
@@ -49,6 +52,10 @@ Add this dependency to your application pom.xml
49
52
- Delete the auto-generated error blocks (on-error-propagate/on-error-continue) before using this module.
50
53
- Place the plugin inside an error block (on-error-propagate/on-error-continue) along with a variable for httpStatus.
51
54
55
+
### Error Handler Config
56
+
Error handler application details have been moved into it's own config.
57
+

58
+
52
59
## HTTP Listener Configuration
53
60
The error response should be changed to the following to send back the populated error message.
54
61
```
@@ -67,7 +74,6 @@ The error response should be changed to the following to send back the populated
67
74
68
75
### General
69
76
70
-
- Takes values for apiName and apiVersion. Current default values will be read from a property file `api.name` and `api.version` respectively.
71
77
- Takes value for the previous error message that needs to be propagated. It has to be of type `array`.
72
78

73
79
- Error section defines from what mule expression should the error be read.
@@ -80,15 +86,48 @@ The error response should be changed to the following to send back the populated
80
86
### Common Errors
81
87
Common HTTP based errors are defined in this section. Users have to provide the message they want to send back on the API error response.
82
88
89
+
A boolean field `Default Error Description` has been enabled. If this is set to true, then the error message will be taken from the error description generated by Mule.
90
+
91
+
If the field is set to false, then whatever literal value is provided on the UI will be used to populate the error message.
92
+
93
+
The default value is `true`.
94
+
83
95

84
96
85
97
### Custom Errors (`,` Delimited)
86
98
87
-
Currently due to a limitation on XML SDK, text based entries are required for custom errors. The number of entries have to match else it will fail to be successfully executed.
99
+
Custom errors are now supported through a user defined JSON or Dataweave File. Users can provide the file through the custom error content section. The default value is `{}`.
88
100
89
-
errorTypes: Have to provided as `,` separated values. Example : DB:BAD_SQL_SYNTAX, ABC:DEF
90
-
errorCodes: Have to provided as `,` separated values. Example : 500, 599
91
-
errorMessages: Have to provided as `,` separated values. Example : SQL Syntax is incorrect, Testing
101
+
Create a custom errors file inside src/main/resources and then reference it as shown in the image. A sample content of the file is provided below.
102
+
103
+
A copy of the file is included in the source code of the plugin. The file is called `sampleCustomErrors.dwl`.
104
+
105
+
**Sample Content**
106
+
```
107
+
%dw 2.0
108
+
output application/java
109
+
---
110
+
{
111
+
"MULE:EXPRESSION": {
112
+
"errorCode": 500,
113
+
"reason": "UNKNOWN",
114
+
"defaultError": error.description,
115
+
"errorType": "MULE:EXPRESSION"
116
+
},
117
+
"UNKNOWN": {
118
+
"errorCode": 500,
119
+
"reason": "UNKNOWN",
120
+
"defaultError": error.description ,
121
+
"errorType": "MULE:EXPRESSION"
122
+
},
123
+
"VALIDATION:INVALID_BOOLEAN": {
124
+
"errorCode": 500,
125
+
"reason": "UNKNOWN",
126
+
"defaultError": error.description, // read error from the application
127
+
"errorType": "MULE:EXPRESSION"
128
+
}
129
+
}
130
+
```
92
131
93
132

94
133
@@ -100,29 +139,20 @@ A correlationId will be used for tracking transactions. The default value is #[c
0 commit comments