Skip to content

Commit 490674d

Browse files
authored
Merge pull request #18 from mulesoft-catalyst/4.2.0
Merge 4.2.0 to Master
2 parents 6b20377 + 0533042 commit 490674d

17 files changed

+640
-532
lines changed

.classpath

Lines changed: 0 additions & 18 deletions
This file was deleted.

.gitignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Git folder #
2+
/.git/
3+
4+
# Compilation folders #
5+
/bin/
6+
/target/
7+
/build/
8+
9+
# Java compile files #
10+
*.class
11+
12+
# Package files #
13+
*.jar
14+
*.war
15+
*.ear
16+
*.db
17+
18+
# Log files #
19+
/*.log
20+
/*.log.*
21+
22+
# Output folders #
23+
/test-output/
24+
25+
# Eclipse files #
26+
.buildpath
27+
.classpath
28+
.cproject
29+
.externalToolBuilders/
30+
.launch
31+
.loadpath
32+
.metadata
33+
.project
34+
.settings/
35+
bin/**
36+
tmp/**
37+
tmp/**/*
38+
*.tmp
39+
*.nak
40+
*.swp
41+
*~.nib
42+
*.pydevproject
43+
local.properties
44+
/src/main/resources/rebel.xml
45+
.springBeans
46+
47+
# IntelliJ Idea files #
48+
.idea
49+
*.iml
50+
51+
# Windows files #
52+
Thumbs.db
53+
Desktop.ini
54+
55+
# OS files #
56+
.DS_Store
57+
.svn
58+
._*
59+
.Spotlight-V100
60+
.Trashes
61+
62+
# User-specific stuff
63+
.idea/**/workspace.xml
64+
.idea/**/tasks.xml
65+
.idea/**/usage.statistics.xml
66+
.idea/**/dictionaries
67+
.idea/**/shelf
68+
69+
# Generated files
70+
.idea/**/contentModel.xml
71+
72+
# Sensitive or high-churn files
73+
.idea/**/dataSources/
74+
.idea/**/dataSources.ids
75+
.idea/**/dataSources.local.xml
76+
.idea/**/sqlDataSources.xml
77+
.idea/**/dynamic.xml
78+
.idea/**/uiDesigner.xml
79+
.idea/**/dbnavigator.xml
80+
81+
# Gradle
82+
.idea/**/gradle.xml
83+
.idea/**/libraries
84+
85+
# Gradle and Maven with auto-import
86+
# When using Gradle or Maven with auto-import, you should exclude module files,
87+
# since they will be recreated, and may cause churn. Uncomment if using
88+
# auto-import.
89+
# .idea/artifacts
90+
# .idea/compiler.xml
91+
# .idea/jarRepositories.xml
92+
# .idea/modules.xml
93+
# .idea/*.iml
94+
# .idea/modules
95+
# *.iml
96+
# *.ipr
97+
98+
# CMake
99+
cmake-build-*/
100+
101+
# Mongo Explorer plugin
102+
.idea/**/mongoSettings.xml
103+
104+
# File-based project format
105+
*.iws
106+
107+
# IntelliJ
108+
out/
109+
110+
# mpeltonen/sbt-idea plugin
111+
.idea_modules/
112+
113+
# JIRA plugin
114+
atlassian-ide-plugin.xml
115+
116+
# Cursive Clojure plugin
117+
.idea/replstate.xml
118+
119+
# Crashlytics plugin (for Android Studio and IntelliJ)
120+
com_crashlytics_export_strings.xml
121+
crashlytics.properties
122+
crashlytics-build.properties
123+
fabric.properties
124+
125+
# Editor-based Rest Client
126+
.idea/httpRequests
127+
128+
# Android studio 3.1+ serialized cache file
129+
.idea/caches/build_file_checksums.ser
130+
.dd05820d-ca95-4a87-acec-bd2e190bf491.pom
131+
.537d0e44-30de-42fa-9981-d8f7b4b4838e.pom

README.md

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This custom error handler plugin allows a single module to process error message
1818
- No specific error type is required for this module. It can parse any error types.
1919
- Propagate errors from sys/prc layer back to exp layer, cementing error propagation across layers.
2020
- 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`
2124

2225
## Operations Supported
2326
On Error
@@ -49,6 +52,10 @@ Add this dependency to your application pom.xml
4952
- Delete the auto-generated error blocks (on-error-propagate/on-error-continue) before using this module.
5053
- Place the plugin inside an error block (on-error-propagate/on-error-continue) along with a variable for httpStatus.
5154

55+
### Error Handler Config
56+
Error handler application details have been moved into it's own config.
57+
![alt text](errorHandlerConfig.png)
58+
5259
## HTTP Listener Configuration
5360
The error response should be changed to the following to send back the populated error message.
5461
```
@@ -67,7 +74,6 @@ The error response should be changed to the following to send back the populated
6774

6875
### General
6976

70-
- Takes values for apiName and apiVersion. Current default values will be read from a property file `api.name` and `api.version` respectively.
7177
- Takes value for the previous error message that needs to be propagated. It has to be of type `array`.
7278
![alt text](previousError.png)
7379
- 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
8086
### Common Errors
8187
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.
8288

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+
8395
![alt text](commonErrors.png)
8496

8597
### Custom Errors (`,` Delimited)
8698

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 `{}`.
88100

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+
```
92131

93132
![alt text](customErrors.png)
94133

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

101140
### On Error With Default Errors
102141
```
103-
<error-handler>
104-
<on-error-propagate enableNotifications="true"
105-
logException="true" doc:name="On Error Propagate" doc:id="b995ec19-3b56-4b8e-8b0f-b172cead9be4">
106-
<error-handler-plugin:on-error doc:name="On error" doc:id="42db8478-b083-48b4-b31f-6638e6a6f18a" />
107-
<set-variable value="#[attributes.httpStatus]"
108-
doc:name="Set Variable" doc:id="2151ced0-a42f-4c0d-b439-455abd354277"
109-
variableName="httpStatus" />
110-
</on-error-propagate>
111-
</error-handler>
142+
<error-handler-plugin:on-error
143+
doc:name="Process Error"
144+
doc:id="5cb355ae-9e1e-4ca8-971e-a63eca2e4c54"
145+
config-ref="Error_Handler_Plugin_Config" />
112146
```
113147

114148
### On Error With Custom Errors
115149
```
116-
<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" doc:id="b995ec19-3b56-4b8e-8b0f-b172cead9be4">
117-
<error-handler-plugin:on-error doc:name="On error"
118-
doc:id="2108e03c-1a96-4dcd-976e-26d9f5f5f158"
119-
errorTypes="DB:BAD_SQL_SYNTAX, ABC:DEF"
120-
errorCodes="500, 599"
121-
errorMessages="SQL Syntax is incorrect, Testing"/>
122-
<set-variable value="#[attributes.httpStatus]"
123-
doc:name="Set Variable" doc:id="2151ced0-a42f-4c0d-b439-455abd354277"
124-
variableName="httpStatus" />
125-
</on-error-propagate>
150+
<error-handler-plugin:on-error
151+
doc:name="Process Error"
152+
doc:id="b5304793-213f-493a-acc9-1d2d5285c39e"
153+
config-ref="Error_Handler_Plugin_Config">
154+
<error-handler-plugin:custom-errors><![CDATA[#[${file::dwl/customErrors.dwl}]]]></error-handler-plugin:custom-errors>
155+
</error-handler-plugin:on-error>>
126156
```
127157

128158
## Contributors

commonErrors.png

-215 KB
Loading

customErrors.png

-180 KB
Loading

errorHandlerConfig.png

19.7 KB
Loading

general.png

-112 KB
Loading

mule-artifact.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"attributes": {
1414
"exportedResources": [
1515
"dwl/customErrors.dwl",
16-
"dwl/defaultErrors.dwl"
16+
"dwl/defaultErrors.dwl",
17+
"dwl/sampleCustomErrors.dwl"
1718
]
1819
}
1920
},

0 commit comments

Comments
 (0)