Error Handling - Part3

Mule 4 Indepth Handling Exceptions in Mule4
29 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.59
List Price:  €93.70
You save:  €28.11
£56.03
List Price:  £80.05
You save:  £24.01
CA$96.39
List Price:  CA$137.71
You save:  CA$41.31
A$107.98
List Price:  A$154.26
You save:  A$46.28
S$95.50
List Price:  S$136.44
You save:  S$40.93
HK$547.57
List Price:  HK$782.28
You save:  HK$234.70
CHF 64.43
List Price:  CHF 92.05
You save:  CHF 27.61
NOK kr776.82
List Price:  NOK kr1,109.79
You save:  NOK kr332.97
DKK kr489.21
List Price:  DKK kr698.91
You save:  DKK kr209.69
NZ$118.81
List Price:  NZ$169.74
You save:  NZ$50.92
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,729.18
List Price:  ৳11,042.16
You save:  ৳3,312.97
₹5,842.93
List Price:  ₹8,347.41
You save:  ₹2,504.47
RM333.67
List Price:  RM476.70
You save:  RM143.02
₦92,745.84
List Price:  ₦132,499.74
You save:  ₦39,753.90
₨19,599.98
List Price:  ₨28,001.17
You save:  ₨8,401.19
฿2,600.12
List Price:  ฿3,714.62
You save:  ฿1,114.50
₺2,271.31
List Price:  ₺3,244.87
You save:  ₺973.56
B$363.64
List Price:  B$519.51
You save:  B$155.87
R1,308.28
List Price:  R1,869.05
You save:  R560.77
Лв128.30
List Price:  Лв183.29
You save:  Лв54.99
₩96,996.60
List Price:  ₩138,572.52
You save:  ₩41,575.91
₪261.41
List Price:  ₪373.46
You save:  ₪112.04
₱4,045.59
List Price:  ₱5,779.67
You save:  ₱1,734.07
¥11,052.75
List Price:  ¥15,790.32
You save:  ¥4,737.57
MX$1,197.81
List Price:  MX$1,711.23
You save:  MX$513.42
QR257.31
List Price:  QR367.61
You save:  QR110.29
P1,000.11
List Price:  P1,428.79
You save:  P428.68
KSh9,335.98
List Price:  KSh13,337.69
You save:  KSh4,001.70
E£3,349.95
List Price:  E£4,785.86
You save:  E£1,435.90
ብር4,013.63
List Price:  ብር5,734.01
You save:  ብር1,720.37
Kz58,409.45
List Price:  Kz83,445.65
You save:  Kz25,036.20
CLP$67,298.07
List Price:  CLP$96,144.23
You save:  CLP$28,846.15
CN¥506.79
List Price:  CN¥724.02
You save:  CN¥217.23
RD$4,121.81
List Price:  RD$5,888.55
You save:  RD$1,766.74
DA9,423.87
List Price:  DA13,463.25
You save:  DA4,039.38
FJ$159.96
List Price:  FJ$228.52
You save:  FJ$68.56
Q547.38
List Price:  Q782
You save:  Q234.62
GY$14,742.16
List Price:  GY$21,061.13
You save:  GY$6,318.97
ISK kr9,832.89
List Price:  ISK kr14,047.59
You save:  ISK kr4,214.70
DH712.24
List Price:  DH1,017.53
You save:  DH305.29
L1,243.01
List Price:  L1,775.81
You save:  L532.79
ден4,046.68
List Price:  ден5,781.23
You save:  ден1,734.54
MOP$564.08
List Price:  MOP$805.87
You save:  MOP$241.78
N$1,315.96
List Price:  N$1,880.02
You save:  N$564.06
C$2,592.36
List Price:  C$3,703.54
You save:  C$1,111.17
रु9,349.94
List Price:  रु13,357.63
You save:  रु4,007.69
S/263.70
List Price:  S/376.73
You save:  S/113.03
K271.96
List Price:  K388.53
You save:  K116.57
SAR262.49
List Price:  SAR375.01
You save:  SAR112.51
ZK1,886.12
List Price:  ZK2,694.57
You save:  ZK808.45
L326.39
List Price:  L466.29
You save:  L139.90
Kč1,650.20
List Price:  Kč2,357.53
You save:  Kč707.33
Ft25,629.21
List Price:  Ft36,614.73
You save:  Ft10,985.52
SEK kr770.71
List Price:  SEK kr1,101.06
You save:  SEK kr330.35
ARS$61,698.11
List Price:  ARS$88,143.94
You save:  ARS$26,445.82
Bs486.86
List Price:  Bs695.54
You save:  Bs208.68
COP$271,471.23
List Price:  COP$387,832.67
You save:  COP$116,361.43
₡35,819.54
List Price:  ₡51,172.97
You save:  ₡15,353.42
L1,740.31
List Price:  L2,486.27
You save:  L745.95
₲526,285.13
List Price:  ₲751,868.13
You save:  ₲225,582.99
$U2,699.91
List Price:  $U3,857.19
You save:  $U1,157.27
zł284.80
List Price:  zł406.88
You save:  zł122.07
Already have an account? Log In

Transcript

Welcome back. This is actually a continuation of the earlier video. In this video, you're going to understand that one error handler. One error handling block can contain multiple error handlers. And also we'll understand about how to configure global error handler for your application. Okay, let's get started.

So, firstly, if you see this flow get product by name flow, we are consuming a soap web service. I want to show you what will happen if I stopped the soap web service. This web service consumer will get a connectivity error is it so I want you to observe what is the error type, which you will be getting once I give a request. Then we will see how to handle specific error types. So, start this application first. Okay, got started.

And if you see the soap web services running, when it is running effectively request I should get proper response now. Yep, I got the response. Now, I'll go and stop the server service by pressing Ctrl C is a soporific Web Services talk. Now, if I give a request to see I got this response is nothing but error message. So, here if you see that occurred here for the exception type error type, error type is W SC namespace cannot dispatch cannot dispatch is a name identifier and namespaces Ws web service consumer which parent is new any. So, this is error type which got propagated.

So here we are having on error propagate what to do to just execute the logger and propagate the color in the color again here, here I'm actually calling here also have on error propagate. So, the logger will be executed and it will be propagated to main flow. In the main flow there is no error handler. So, the default error handler is executed which will actually done the stack trace on the console terminate the flow. Let's see, practice is dumb terminate the flow and then the error, this listener will return error responses. So if you see responses and error response, I have configured it already in earlier video to reply error dot error.

So that's what I got error dot error type. Okay. Now, let's assume that in a particular flow, we are calling multiple web services. That means in this Get Products by name, I, let's assume that I am also consuming another soap web service. So just drag and drop just to show you go to service consumer, let's assume that even if to consume one more web service and another operation right. So, let's assume that the other web service also is down.

So, this first one is consuming some first web service second is consuming another web service assume that both of the web server is down. So, what is the error message you will be getting what is the error type you can observe in this honor propagate the error type will be same w SQL cannot distract. So, in this error handler cannot really understand whether the exception came from here or here all right, both of them will be throwing same error time right. So, we cannot rely on And whether exception came from here, or here. Alright, so what we can do is right now I'll delete this service. What we can do is, in the component itself web service consume component itself, we can map the standard error types to our one.

What we can do is we can double click on consume component in the error mapping block. You can see what I just did this in the error mapping block. I can add a new mapping for what I want to map Ws sequel, connectivity, and what is my customer tell you app namespace. Let's see what error Let's say the customer type okay. So it got added. Now what I want to do is I want to handle specific error type so let me just copy paste Exactly.

Okay. Now I want to and we'll see where it takes specially in their handling block. Actually one error handling block can have multiple error handling. So what I'll do is I'll drag and drop one more I will say on error contain So honor continue, I want to first order matters and drag and drop it about nice on the Navy trying to drag and drop. convention Confederate elder is I will delete this and again it's always coming down. So what I will do is I'll delete this honor propagate and then I will again add on or propagate here.

Yes. So in one error handling Doc, I have two handlers. What I'm going to do is your lead logger to both of them. In the first logger, I will write a log expression that will secure the first logger I write inside. On GRE can be no error type is admission. So actually what I want to do is whenever Aaron Block contains two error handlers, which specific which error handler has to be executed when cell double click on on error continue here we can map for what all error types this has to be mapped.

So it can search here. So see here, app called server type is listed data census working right. So here I map, app column server. And even not only the type it can map this honor continue to be executed ways or some conditions Okay. What you can do is you can add some condition like error dot error message is equals to decide what our conditions which will evaluate to true are So, what condition to write in this one you'll get a clearer idea better always during development keep a debug point here and see what all out all objects are available in the debug mode when the control is inside the on error continue right inside here. So then you will get an idea about what else conditions you can write here and when when, okay.

So, now I have written this See, you can see on error continue here the type is appearing as server error type. And in this logger, I just write insight on it. Now, I want this honor propagate to be mapped for any of the error types. Actually I didn't specify the type here. If I don't specify the type by default it maps to any any not even specifying any any few nodes a parent for all their types visit new column any. So, I have configured both of them and what I will do is I will try to drag and drop set pay node here in honor continue and here in the payload, I will write error dot error type okay And the mind data mine type of this, I know that it is application slash Jason Okay.

So now I will run this okay it's already existing stop a tenant I will run for 20 okay got deployed let you request now. Observe the console. Yeah Here it is specifying WC column dispatch. Check here. loggers insight on error propagation. Inside validate flow honor profit oh actually what is the love I wrote here?

Oh, it is coming as oh this is getting scared as it instead honor propagate but executed. Actually a map it exactly here error mapping WC colon connectivity actually the error was WC con cannot dispatch Oh Was it a different era which I have to map actually let me get ready but After the work and see what is happening here are I think I missed that one more thing also, as of now WC colon cannot dispatch I guess this was the I'd say app called Siva can dispatch my own life. So I'm happy to. Okay. What I'll do is I'll copy this and here in honor continue. I would write types as this one.

Also what Okay, I saved it and hopefully this application should restart and save again this should restart Okay, restarted. Oh, let me clear apparently I did. Okay. I do request again. Yep. Now I got some junk while you That's okay.

I'm here to see the locks Yeah, now I got inside on error continue out loud or I will turn the logs. Okay and the payload Since I made as Jason error dot errata, maybe just check the response. Actually some messages, error type, see what cannot dispatch. There was not converted to JSON properly. Maybe I didn't write the expression properly. Is it?

I got an object actually error type implementation, something like that. Okay. Nice. Yes. But you saw that this got executed I said. Yes.

So now I wanted actually to understand, I wanted you to understand that in error handling block, we can have multiple error handlers. But whenever you're having multiple handlers, you have to tell with first error handlers To be executed when for whatever types and you can even specify when condition. So like that we can have a number of error handlers in error handling block, we can, we can map them by specifying the appropriate types and also conditions. And the last handler need not have a type specified. By default, if you don't specify the type it is any mewling space. And that is what I want you to understand.

Now, I want to configure a global error handler. This error handling handler is only for this particular flow. Every flow is having its one error. Now, I want to configure it global error handler. So what I can do is simply in the core, I have error handler I will drag and drop it outside of all calls center handler which is outside of all the flows is global. So, what I can do is try to drag and drop this on error continue inside this global handler yes and honor propagate also.

Insert this Yes. So I have configured and globally. Now, what I can do is I can go to global elements create under configuration Configure default error handler I want to make my global handlers default. I specified that this is a default handler. So if you see the XML here, this is a global error handler. And you can observe that configuration tag here default error handler ref is equals to this error handler, okay.

Now you observe that my Get Products by name is not having any error handler. But this validate in transfer was having one error. Since I didn't configure any error handler. Here in the good parts by name, I expect that this should be expected. So Yeah, really private is done. For clientele stop and started no problem.

I'm stopping it. Okay, and now for you same request I should get the same response. Right? So, we answered about how to configure default error handler. Right. There is no exception handling block here.

Automatically code executed. Okay. No, an important part for certification. This question an hour I'm going to talk about may come in certification if you're planning for certification. So what I will do is let me drag and drop one more on error propagate in the error handling block of get by name and then I will just drag and drop on lava to it. And for this lager I'm going to write here inside on and off Get Products widely okay on error propagate so I expect that this is executed and propagated.

Right and should be propagated so let's see Now what will happen? Do I expect this also to be executed? Let us see. I guess it's restarted as I said, Okay. So I'll give a request now. So I got it.

Let me actually see the console. In the console, what are all the logs chicken observe inside on error propagate of Get Products by name. And then since there is an error handler, in his get parts when in the default was not executed, right? The default was not executed. But today, configure some condition here. called for our error propagate.

No has a flow intentionally I will specify the type as it's a bad request okay. So, this error handler is no mapping only bad request. Actually the error which is coming is cannot dispatch. Now this is having bad request. So this will not map. So, since this does not map Do you expect the global one to be executed?

Let's see. I guess it should have restarted but for clarity, I will restart it. stopping it first and let's talk Okay, started your request Yeah, now I'm seeing that this is the response same response I got to check here on the console. Noisy a logger from do I see a logger from this one? All right. This logger is not printed so it is not matched.

So what happened? When exception came, there is no error handling, which isn't just matching here. Right. And since we have an error handler with a default error handler excluded, no. It will propagate the color here what we are doing, we are again logging this by writing invalidate and transform, we are propagating it again, again it goes here, it gets propagated for the main flow, there is no handler at all, there is no handler at all. So, the default got executed.

That's why we are seeing that output is it. So, I can see on the logger saw the log from validated in the valid flow and this is again the log from the global error handler. Now, the important thing I want to discuss here is I will actually Same thing on error propagate. Okay, Drag and drop in the main flow quickly on error propagate on the main floor and quickly drag and drop a logger and here I'm going right in main flow on error Okay. So now, when the control comes to mean flow I am handling it but here for this I will write some condition which is not matching. So read the type or something like that which is not valid Right.

So, an exception comes to mean flow, but I have an error handler which is not matching. So do you think this one will get executed? No. So, let us see what will happen again, I will have saved it and I'll give a request now. Got restarted. Okay the console and then I'll give a request.

Yep, this I got see what cannot dispatch but let us see on the logs. What is excluded only invalid Flow I can see I cannot see the log from the global error handler. So what I want you to understand for certification, this is a question. If in your flows we have an error handler is not matching anything, the default one will not get executed. Okay. I will explain you about various scenarios in my next video.

See you next week.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.