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
€67.35
List Price:  €96.21
You save:  €28.86
£55.83
List Price:  £79.77
You save:  £23.93
CA$100.76
List Price:  CA$143.95
You save:  CA$43.19
A$112.23
List Price:  A$160.33
You save:  A$48.10
S$95.14
List Price:  S$135.93
You save:  S$40.78
HK$543.62
List Price:  HK$776.63
You save:  HK$233.01
CHF 63.04
List Price:  CHF 90.06
You save:  CHF 27.02
NOK kr797.48
List Price:  NOK kr1,139.30
You save:  NOK kr341.82
DKK kr502.49
List Price:  DKK kr717.87
You save:  DKK kr215.38
NZ$124.10
List Price:  NZ$177.29
You save:  NZ$53.19
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,361.55
List Price:  ৳11,945.58
You save:  ৳3,584.03
₹5,962.79
List Price:  ₹8,518.63
You save:  ₹2,555.84
RM314.04
List Price:  RM448.65
You save:  RM134.61
₦108,335.42
List Price:  ₦154,771.52
You save:  ₦46,436.10
₨19,495.71
List Price:  ₨27,852.21
You save:  ₨8,356.49
฿2,390.81
List Price:  ฿3,415.60
You save:  ฿1,024.78
₺2,467.44
List Price:  ₺3,525.07
You save:  ₺1,057.62
B$434.14
List Price:  B$620.23
You save:  B$186.09
R1,296.68
List Price:  R1,852.48
You save:  R555.80
Лв131.68
List Price:  Лв188.12
You save:  Лв56.44
₩102,198.93
List Price:  ₩146,004.73
You save:  ₩43,805.79
₪256.56
List Price:  ₪366.53
You save:  ₪109.97
₱4,090.81
List Price:  ₱5,844.26
You save:  ₱1,753.45
¥10,994.99
List Price:  ¥15,707.80
You save:  ¥4,712.81
MX$1,408.98
List Price:  MX$2,012.91
You save:  MX$603.93
QR255.09
List Price:  QR364.43
You save:  QR109.34
P967.82
List Price:  P1,382.66
You save:  P414.84
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,562.49
List Price:  E£5,089.49
You save:  E£1,527
ብር8,907.19
List Price:  ብር12,725.10
You save:  ብር3,817.91
Kz63,830.88
List Price:  Kz91,190.88
You save:  Kz27,360
CLP$69,323.69
List Price:  CLP$99,038.09
You save:  CLP$29,714.40
CN¥510.80
List Price:  CN¥729.75
You save:  CN¥218.94
RD$4,245.36
List Price:  RD$6,065.06
You save:  RD$1,819.70
DA9,465.07
List Price:  DA13,522.10
You save:  DA4,057.03
FJ$162.39
List Price:  FJ$232
You save:  FJ$69.60
Q539.11
List Price:  Q770.19
You save:  Q231.08
GY$14,638.77
List Price:  GY$20,913.42
You save:  GY$6,274.65
ISK kr9,772.70
List Price:  ISK kr13,961.60
You save:  ISK kr4,188.90
DH703.98
List Price:  DH1,005.73
You save:  DH301.75
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,143.97
List Price:  ден5,920.21
You save:  ден1,776.24
MOP$559.97
List Price:  MOP$800
You save:  MOP$240.02
N$1,289.45
List Price:  N$1,842.15
You save:  N$552.70
C$2,574.80
List Price:  C$3,678.44
You save:  C$1,103.64
रु9,534.71
List Price:  रु13,621.60
You save:  रु4,086.89
S/260.99
List Price:  S/372.86
You save:  S/111.86
K283.85
List Price:  K405.52
You save:  K121.66
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,936.45
List Price:  ZK2,766.47
You save:  ZK830.02
L335.12
List Price:  L478.77
You save:  L143.64
Kč1,694.03
List Price:  Kč2,420.15
You save:  Kč726.12
Ft27,771.44
List Price:  Ft39,675.18
You save:  Ft11,903.74
SEK kr774.38
List Price:  SEK kr1,106.30
You save:  SEK kr331.92
ARS$71,792.58
List Price:  ARS$102,565.23
You save:  ARS$30,772.64
Bs484.55
List Price:  Bs692.24
You save:  Bs207.69
COP$307,165.41
List Price:  COP$438,826.54
You save:  COP$131,661.12
₡35,530.54
List Price:  ₡50,760.09
You save:  ₡15,229.55
L1,777.33
List Price:  L2,539.15
You save:  L761.82
₲546,250
List Price:  ₲780,390.60
You save:  ₲234,140.59
$U3,115.91
List Price:  $U4,451.49
You save:  $U1,335.58
zł287.82
List Price:  zł411.19
You save:  zł123.37
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.