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.