Skip to content

Commit ffc0be3

Browse files
author
biswa-mohanty
committed
4.2.0 code base
1 parent 3f3a34d commit ffc0be3

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: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Error Plugin for Mule 4.2.x
22

3-
**This is only for minimum Mule version 4.2.x onwards**
3+
**This is only for minimum Mule version 4.2.0 onwards**
44

55
This custom error handler plugin allows a single module to process error messages from multiple types:
66
- Error types default to mule. (HTTP, APIKIT, Connectors based, etc)
@@ -11,6 +11,9 @@ This custom error handler plugin allows a single module to process error message
1111
- No specific error type is required for this module. It can parse any error types.
1212
- Propagate errors from sys/prc layer back to exp layer, cementing error propagation across layers.
1313
- To propagate the errors, ensure the appropriate variable name is referenced in the previous error section.
14+
- Support for Mule error components to be factored into the error message based on boolean fields.
15+
- Using Mule Error components will give very prescriptive error messages.
16+
- Support for debug log package: `org.mulesoft.modules.errorhandler`
1417

1518
## Operations Supported
1619
On Error
@@ -42,6 +45,10 @@ Add this dependency to your application pom.xml
4245
- Delete the auto-generated error blocks (on-error-propagate/on-error-continue) before using this module.
4346
- Place the plugin inside an error block (on-error-propagate/on-error-continue) along with a variable for httpStatus.
4447

48+
### Error Handler Config
49+
Error handler application details have been moved into it's own config.
50+
![alt text](errorHandlerConfig.png)
51+
4552
## HTTP Listener Configuration
4653
The error response should be changed to the following to send back the populated error message.
4754
```
@@ -60,7 +67,6 @@ The error response should be changed to the following to send back the populated
6067

6168
### General
6269

63-
- Takes values for apiName and apiVersion. Current default values will be read from a property file `api.name` and `api.version` respectively.
6470
- Takes value for the previous error message that needs to be propagated. It has to be of type `array`.
6571
![alt text](previousError.png)
6672
- Error section defines from what mule expression should the error be read.
@@ -73,15 +79,48 @@ The error response should be changed to the following to send back the populated
7379
### Common Errors
7480
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.
7581

82+
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.
83+
84+
If the field is set to false, then whatever literal value is provided on the UI will be used to populate the error message.
85+
86+
The default value is `true`.
87+
7688
![alt text](commonErrors.png)
7789

7890
### Custom Errors (`,` Delimited)
7991

80-
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.
92+
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 `{}`.
8193

82-
errorTypes: Have to provided as `,` separated values. Example : DB:BAD_SQL_SYNTAX, ABC:DEF
83-
errorCodes: Have to provided as `,` separated values. Example : 500, 599
84-
errorMessages: Have to provided as `,` separated values. Example : SQL Syntax is incorrect, Testing
94+
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.
95+
96+
A copy of the file is included in the source code of the plugin. The file is called `sampleCustomErrors.dwl`.
97+
98+
**Sample Content**
99+
```
100+
%dw 2.0
101+
output application/java
102+
---
103+
{
104+
"MULE:EXPRESSION": {
105+
"errorCode": 500,
106+
"reason": "UNKNOWN",
107+
"defaultError": error.description,
108+
"errorType": "MULE:EXPRESSION"
109+
},
110+
"UNKNOWN": {
111+
"errorCode": 500,
112+
"reason": "UNKNOWN",
113+
"defaultError": error.description ,
114+
"errorType": "MULE:EXPRESSION"
115+
},
116+
"VALIDATION:INVALID_BOOLEAN": {
117+
"errorCode": 500,
118+
"reason": "UNKNOWN",
119+
"defaultError": error.description, // read error from the application
120+
"errorType": "MULE:EXPRESSION"
121+
}
122+
}
123+
```
85124

86125
![alt text](customErrors.png)
87126

@@ -93,29 +132,20 @@ A correlationId will be used for tracking transactions. The default value is #[c
93132

94133
### On Error With Default Errors
95134
```
96-
<error-handler>
97-
<on-error-propagate enableNotifications="true"
98-
logException="true" doc:name="On Error Propagate" doc:id="b995ec19-3b56-4b8e-8b0f-b172cead9be4">
99-
<error-handler-plugin:on-error doc:name="On error" doc:id="42db8478-b083-48b4-b31f-6638e6a6f18a" />
100-
<set-variable value="#[attributes.httpStatus]"
101-
doc:name="Set Variable" doc:id="2151ced0-a42f-4c0d-b439-455abd354277"
102-
variableName="httpStatus" />
103-
</on-error-propagate>
104-
</error-handler>
135+
<error-handler-plugin:on-error
136+
doc:name="Process Error"
137+
doc:id="5cb355ae-9e1e-4ca8-971e-a63eca2e4c54"
138+
config-ref="Error_Handler_Plugin_Config" />
105139
```
106140

107141
### On Error With Custom Errors
108142
```
109-
<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" doc:id="b995ec19-3b56-4b8e-8b0f-b172cead9be4">
110-
<error-handler-plugin:on-error doc:name="On error"
111-
doc:id="2108e03c-1a96-4dcd-976e-26d9f5f5f158"
112-
errorTypes="DB:BAD_SQL_SYNTAX, ABC:DEF"
113-
errorCodes="500, 599"
114-
errorMessages="SQL Syntax is incorrect, Testing"/>
115-
<set-variable value="#[attributes.httpStatus]"
116-
doc:name="Set Variable" doc:id="2151ced0-a42f-4c0d-b439-455abd354277"
117-
variableName="httpStatus" />
118-
</on-error-propagate>
143+
<error-handler-plugin:on-error
144+
doc:name="Process Error"
145+
doc:id="b5304793-213f-493a-acc9-1d2d5285c39e"
146+
config-ref="Error_Handler_Plugin_Config">
147+
<error-handler-plugin:custom-errors><![CDATA[#[${file::dwl/customErrors.dwl}]]]></error-handler-plugin:custom-errors>
148+
</error-handler-plugin:on-error>>
119149
```
120150

121151
## 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)