Skip to content

Commit 52b99a6

Browse files
author
Prabhakar Kommera
committed
420 Fixes
1 parent 977ee14 commit 52b99a6

File tree

8 files changed

+247
-169
lines changed

8 files changed

+247
-169
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Error Plugin for Mule 4
1+
# Error Plugin for Mule 4.2.x
2+
3+
**This is only for minimum Mule version 4.2.x onwards**
24

35
This custom error handler plugin allows a single module to process error messages from multiple types:
46
- Error types default to mule. (HTTP, APIKIT, Connectors based, etc)
@@ -7,6 +9,8 @@ This custom error handler plugin allows a single module to process error message
79
- User can change the custom error message (for multiple errors) in the UI rather than in the XML.
810
- Users intending to use other error types should put them on on-error-propagate or on-error-continue prior to using this module.
911
- No specific error type is required for this module. It can parse any error types.
12+
- Propagate errors from sys/prc layer back to exp layer, cementing error propagation across layers.
13+
- To propagate the errors, ensure the appropriate variable name is referenced in the previous error section.
1014

1115
## Operations Supported
1216
On Error
@@ -42,21 +46,23 @@ Add this dependency to your application pom.xml
4246
The error response should be changed to the following to send back the populated error message.
4347
```
4448
<http:listener doc:name="Listener" doc:id="1d3566ad-c8dc-4b8a-ab45-338625c74afb" config-ref="HTTP_Listener_config" path="/error">
45-
<http:response statusCode="#[vars.httpStatus default 200]">
46-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
47-
</http:response>
48-
<http:error-response statusCode="#[vars.httpStatus default 500]">
49-
<http:body>#[payload]</http:body>
50-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
51-
</http:error-response>
52-
</http:listener>
49+
<http:response statusCode="#[vars.httpStatus default 200]">
50+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
51+
</http:response>
52+
<http:error-response statusCode="#[vars.httpStatus default 500]">
53+
<http:body>#[payload]</http:body>
54+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
55+
</http:error-response>
56+
</http:listener>
5357
```
5458

5559
## Tabs
5660

5761
### General
5862

5963
- Takes values for apiName and apiVersion. Current default values will be read from a property file `api.name` and `api.version` respectively.
64+
- Takes value for the previous error message that needs to be propagated. It has to be of type `array`.
65+
![alt text](previousError.png)
6066
- Error section defines from what mule expression should the error be read.
6167
- httpStatus set variable is required to send back the httpStatus on the http response
6268

general.png

-64.1 KB
Loading

pom.xml

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<groupId>ORG_ID_TOKEN</groupId>
6+
<groupId>70ae4654-16a5-480b-afb1-3d728b24a317</groupId>
77
<artifactId>common-error-handler</artifactId>
8-
<version>2.0.0</version>
8+
<version>3.0.1</version>
99
<packaging>mule-extension</packaging>
1010

1111
<name>error-handler-plugin</name>
1212
<description>A Mule extension done with pure Mule DSL</description>
1313

14-
<parent>
15-
<groupId>org.mule.extensions</groupId>
16-
<artifactId>mule-modules-parent</artifactId>
17-
<version>1.1.1</version>
18-
</parent>
19-
2014
<properties>
2115
<!-- XML SDK properties -->
2216
<mule.version>4.1.5</mule.version>
2317
<mule.extensions.maven.plugin.version>1.1.5</mule.extensions.maven.plugin.version>
24-
18+
<munit.version>2.1.3</munit.version>
19+
<munit.extensions.maven.plugin.version>1.0.0-BETA</munit.extensions.maven.plugin.version>
20+
<munit.input.directory>src/test/munit</munit.input.directory>
21+
<munit.output.directory>${basedir}/target/test-mule/munit</munit.output.directory>
2522
<maven.source.plugin.version>3.0.1</maven.source.plugin.version>
2623
<maven.resources.plugin.version>3.1.0</maven.resources.plugin.version>
2724
<maven.clean.plugin.version>3.1.0</maven.clean.plugin.version>
@@ -32,14 +29,14 @@
3229
<maven.javadoc.plugin.version>3.0.1</maven.javadoc.plugin.version>
3330
<maven.surefire.plugin.version>2.22.0</maven.surefire.plugin.version>
3431
<app.runtime>4.1.5</app.runtime>
35-
<mule.module.http.version>1.5.6</mule.module.http.version>
32+
<mule.module.http.version>1.2.0</mule.module.http.version>
3633
</properties>
3734

3835
<distributionManagement>
3936
<repository>
4037
<id>Exchange2</id>
4138
<name>Mule Repo</name>
42-
<url>https://maven.anypoint.mulesoft.com/api/v1/organizations/${project.groupId}/maven</url>
39+
<url>https://maven.anypoint.mulesoft.com/api/v1/organizations/${groupId}/maven</url>
4340
<layout>default</layout>
4441
</repository>
4542
</distributionManagement>
@@ -60,37 +57,60 @@
6057
<version>${mule.version}</version>
6158
<scope>provided</scope>
6259
</dependency>
60+
<!--MUnit Dependencies -->
6361
<dependency>
64-
<groupId>org.mule.connectors</groupId>
65-
<artifactId>mule-http-connector</artifactId>
66-
<version>${mule.module.http.version}</version>
67-
<classifier>mule-plugin</classifier>
68-
</dependency>
69-
70-
<dependency>
71-
<groupId>org.mule.module</groupId>
72-
<artifactId>mule-java-module</artifactId>
73-
<version>1.1.1</version>
62+
<groupId>com.mulesoft.munit</groupId>
63+
<artifactId>munit-runner</artifactId>
64+
<version>${munit.version}</version>
7465
<classifier>mule-plugin</classifier>
66+
<scope>test</scope>
7567
</dependency>
7668
<dependency>
77-
<groupId>org.mule.modules</groupId>
78-
<artifactId>mule-validation-module</artifactId>
79-
<version>1.1.0</version>
69+
<groupId>com.mulesoft.munit</groupId>
70+
<artifactId>munit-tools</artifactId>
71+
<version>2.1.3</version>
8072
<classifier>mule-plugin</classifier>
8173
</dependency>
8274
</dependencies>
8375

8476
<build>
8577
<pluginManagement>
8678
<plugins>
87-
79+
<plugin>
80+
<groupId>com.mulesoft.munit</groupId>
81+
<artifactId>munit-extensions-maven-plugin</artifactId>
82+
<version>${munit.extensions.maven.plugin.version}</version>
83+
<executions>
84+
<execution>
85+
<id>munit-extension-test</id>
86+
<phase>integration-test</phase>
87+
<goals>
88+
<goal>test</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
8893
<plugin>
8994
<groupId>org.apache.maven.plugins</groupId>
9095
<artifactId>maven-resources-plugin</artifactId>
9196
<version>${maven.resources.plugin.version}</version>
9297
<executions>
93-
98+
<execution>
99+
<id>copy-munit-resources</id>
100+
<phase>process-test-resources</phase>
101+
<goals>
102+
<goal>copy-resources</goal>
103+
</goals>
104+
<configuration>
105+
<outputDirectory>${munit.output.directory}</outputDirectory>
106+
<resources>
107+
<resource>
108+
<directory>${munit.input.directory}</directory>
109+
<filtering>true</filtering>
110+
</resource>
111+
</resources>
112+
</configuration>
113+
</execution>
94114
</executions>
95115
</plugin>
96116
<!-- Maven Plugins -->
@@ -139,7 +159,10 @@
139159
<version>${mule.extensions.maven.plugin.version}</version>
140160
<extensions>true</extensions>
141161
</plugin>
142-
162+
<plugin>
163+
<groupId>com.mulesoft.munit</groupId>
164+
<artifactId>munit-extensions-maven-plugin</artifactId>
165+
</plugin>
143166
</plugins>
144167
</build>
145168

pom.xml.bkp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>70ae4654-16a5-480b-afb1-3d728b24a317</groupId>
7+
<artifactId>common-error-handler</artifactId>
8+
<version>3.0.0</version>
9+
<packaging>mule-extension</packaging>
10+
11+
<name>error-handler-plugin</name>
12+
<description>A Mule extension done with pure Mule DSL</description>
13+
14+
<properties>
15+
<!-- XML SDK properties -->
16+
<mule.version>4.2.0</mule.version>
17+
<mule.extensions.maven.plugin.version>1.2.0</mule.extensions.maven.plugin.version>
18+
<app.runtime>4.2.0</app.runtime>
19+
<mule.module.http.version>1.5.11</mule.module.http.version>
20+
</properties>
21+
22+
<distributionManagement>
23+
<repository>
24+
<id>Exchange2</id>
25+
<name>Mule Repo</name>
26+
<url>https://maven.anypoint.mulesoft.com/api/v1/organizations/${project.groupId}/maven</url>
27+
<layout>default</layout>
28+
</repository>
29+
</distributionManagement>
30+
31+
32+
<dependencies>
33+
<!--Needed to discover the 'xml-based' XmlExtensionLoader for smart connectors -->
34+
<dependency>
35+
<groupId>org.mule.runtime</groupId>
36+
<artifactId>mule-module-extensions-xml-support</artifactId>
37+
<version>${mule.version}</version>
38+
<scope>provided</scope>
39+
</dependency>
40+
<!-- DataWeave -->
41+
<dependency>
42+
<groupId>com.mulesoft.mule.runtime.modules</groupId>
43+
<artifactId>mule-module-spring-config-ee</artifactId>
44+
<version>${mule.version}</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.mule.connectors</groupId>
49+
<artifactId>mule-http-connector</artifactId>
50+
<version>${mule.module.http.version}</version>
51+
<classifier>mule-plugin</classifier>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.mule.module</groupId>
56+
<artifactId>mule-java-module</artifactId>
57+
<version>1.2.5</version>
58+
<classifier>mule-plugin</classifier>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.mule.modules</groupId>
62+
<artifactId>mule-validation-module</artifactId>
63+
<version>1.4.0</version>
64+
<classifier>mule-plugin</classifier>
65+
</dependency>
66+
</dependencies>
67+
68+
<build>
69+
<pluginManagement>
70+
<plugins>
71+
72+
</plugins>
73+
</pluginManagement>
74+
<plugins>
75+
<plugin>
76+
<!-- Build plugin for XML SDK extension -->
77+
<groupId>org.mule.runtime.plugins</groupId>
78+
<artifactId>mule-extensions-maven-plugin</artifactId>
79+
<version>${mule.extensions.maven.plugin.version}</version>
80+
<extensions>true</extensions>
81+
</plugin>
82+
83+
</plugins>
84+
</build>
85+
86+
<repositories>
87+
<repository>
88+
<id>mulesoft-releases</id>
89+
<name>MuleSoft Releases Repository</name>
90+
<url>http://repository.mulesoft.org/releases/</url>
91+
<layout>default</layout>
92+
</repository>
93+
<repository>
94+
<id>mulesoft-snapshots</id>
95+
<name>MuleSoft Snapshots Repository</name>
96+
<url>https://repository.mulesoft.org/snapshots/</url>
97+
<layout>default</layout>
98+
</repository>
99+
</repositories>
100+
101+
</project>

previousError.png

16.8 KB
Loading
Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
{
2-
"type": "object",
3-
"properties": {
4-
"success": {
5-
"type": "boolean"
6-
},
7-
"apiName":{
8-
"type": "string"
9-
},
10-
"version":{
11-
"type": "string"
12-
},
13-
"correlationId": {
14-
"type": "string"
15-
},
16-
"timestamp":{
17-
"type": "string"
18-
},
19-
"errorDetails":{
20-
"type": "object",
21-
"properties": {
22-
"errorCode": {
23-
"type":"string"
24-
},
25-
"message":{
26-
"type":"string"
27-
},
28-
"additionalInfo":{
29-
"type":"object"
30-
}
31-
32-
}
33-
}
34-
},
35-
"additionalProperties": false
2+
"type": "object",
3+
"properties": {
4+
"success": {
5+
"type": "boolean"
6+
},
7+
"apiName": {
8+
"type": "string"
9+
},
10+
"version": {
11+
"type": "string"
12+
},
13+
"correlationId": {
14+
"type": "string"
15+
},
16+
"timestamp": {
17+
"type": "string"
18+
},
19+
"errorDetails": {
20+
"type": "array",
21+
"items": [
22+
{
23+
"type": "object",
24+
"properties": {
25+
"code": {
26+
"type": "integer"
27+
},
28+
"message": {
29+
"type": "string"
30+
},
31+
"additionalInfo": {
32+
"type": "string"
33+
}
34+
},
35+
"required": [
36+
"code",
37+
"message",
38+
"additionalInfo"
39+
]
40+
}
41+
]
42+
}
43+
},
44+
"additionalProperties": false
3645
}

0 commit comments

Comments
 (0)