Talend - "Die on error" on component vs tRunjob - error-handling

I have a talend main job (Single tRunjob) with error handling, the main job calls a subjob which has three "tRunjob" each has to execute sequentially one after the other on "On subjob ok" trigger. In order to test the main job error handling, I gave a wrong source file name to the "tDelimitedinputfile" component on the second tRunjob. When i executed the main job, instead of failing the Main job completed successfully, "Die on error" is enabled on all tRunjob in the sub and in the main job. Only after I enabled the "Die on error" in the "tDelimitedinputfile" component of the second job the main job is failing. so the question is
Do we have to manually enable "Die on error" on each component inspite "Die on error" being enabled on the tRunjob?

Yes.
The components have to throw the error forward to the job, which in turn will only throw the error forward if itself has the option enabled.
There are no downsides to this. Reason for this is that some jobs or components don't need any error handling.

You do not have to set DieOnError for all Components. In the case of TInputFileDelimited, it is not considered an error if there is a missing file, unless you check the box. Seems odd; but that's the way it is with this component.
Always look for the checkbox on components so that you'll know how they behave.

Related

In AHK, what is the difference between Try/Catch and OnError()? When to use one or the other?

I am currently writing an AHK script that reads and writes files.
I would like to handle the possible I/O errors,
but the doc isn't clear to me regarding wether I should use Try/Catch or OnError().
What is the difference between the two? And when to use one or the other?
So, after some more research, here is my understanding:
Try/Catch: Use it to:
Specifically identify certain lines of code over which it will be applied.
Then, if you would like, proceed with the execution.
A Try/Catch allows to proceed with the execution of the command after the Try block that failed.
(But, a Try/Catch does not allow to proceed with the execution of the command after the one that failed within the Try block. For example if 5 commands are wrapped, then if the 2nd one threw, it will not be possible to proceed with the execution from the 3rd after doing something in the Catch-block.)
OnError(): Use it to
Deal with any unhandled error.
Block (or not) the default error dialog.
In any cases the thread execution is stopped after you handled the error.
There can be multiple OnError() handlers active at a time,
and you can decide, in which order they will be executed (or to stop the execution after any one of them) when an error occurs.
If all handlers return 0 all handlers are called one after the other, then the default error message is displayed, then the thread exits.
If any handler returns a non-zero integer, the thread exits without calling the following handlers and without displaying the default error dialog.

Why in mulesoft "on Error Propagate" rethrows the same error?

I am new to mulesoft and while studing it i strugle to understand why on module "onErrorPropagate" the error is being rethrown after executing the scope.
can you explain the benefits?
An on-error-propagate will rollback any transactions, execute, and use that result to rethrow the existing error––meaning its owner will be considered as “failing.”
The best use is in a layered system, to allow each layer to do its own small part of an error response.
If you are familiar with Java you can think of it as catching the exception and re-throwing it. For example, sometimes you want to do something with the error yourself, but still want to propagate it upwards for higher levels to deal with.
You could add logging in a specific flow for the error but then leave it to the parent flows to actually deal with the exception.
The "onErrorPropagate" propagates (rethrows) the error to the parent flow (or the global error handler if it's already reached the main flow).
This can be usefull in a few cases.
Say you have some flow specific error handling (e.g. if something goes wrong, set a default payload).
Then you propagate this error to the next level where you have your Global error handler that, say, stores some info in a QA database.
You don't want to have that database connector in every single error handler.
In this way you can achieve a 'java inherritance' like structure, for your errors.
Side note: if you want your error to only be handled and do nothing further, you can use "onErrorContinue"

Flow resuming in mulesoft

Problem I am facing is I am using a for each component for iterating the records one by one and then inserting in to some end system.
What exactly is happening is when the data is correct it inserts the data into end system but as there is some exception in the data , exception handling code is executed but the flow do not resumes back in for loop so that all other records gets executed.
I have tried adding sublow and then calling it from flow but while adding a exception handling in sub flow gives me error as "invalid content in custom or catch or choice exception handling"
How to resumes the flow after executing the exception/error handling block.
.
SubFlows can't have endpoints or exception strategies that's why you're getting this error.
Never the less you could just use a normal flow instead of your subflow.
If it has no endpoint then it's call a private flow and can only be referenced from inside your application.
HTH.
You can go with two options here.
1. Use batch processing which can give you list of elements which are processed either successfully and failed.
2. Use until success scope
First, remember that as soon as a processor in ANY scope (flow, try, etc.) raises an error, after the error handler runs (regardless of the level of the handler: app-default, flow-scope, or try-scope) and regardless of whether the error-scope in the error-handler is On Error Propogate or On Error Continue, NO, repeat NO, other processors in that scope are executed.
The pattern that gets you what you want his this:
Wrap a processor (or series of processors) in a given scope into a Try Scope. (note, the easiest way to do this is to select the desired processors, right-click, and in the pop-up, click "Wrap in..." and then in the resulting fly-out - "try".
Drop an On Error Continue error-scope into the Error Handling section of the Try Scope.
Handle the error however you want in the error-scope. This can include NO processors, which treats the error as a no-op.
Thus, when the processor of concern throws the error, no further processors in that Try Scope get called, BUT, after running the Try Scope's On Error Continue error-scope's processor, processing will continue in the parent scope (in this case the flow) and you get to keep processing the elements in your collection.
NOTE: It is correct that a Subflow cannot have an error handler of its own. HOWEVER, it is important to point out that Subflows run in the context of their parent / calling scope (e.g. a Flow / Private Flow), which CAN have error handlers. So, if you have Flows A and B with their error-handlers A' and B', and Subflow C, and Flows A and B each call Subflow C through a flow reference, and further suppose you have processor P1 in C that flows an error, THEN:
When P1 runs being called from Flow A, control passes to A'
When P1 runs being called from Flow B, control passes to B'.
NOTE2: Until Successful will not help the iteration. It will only repeat the attempt to send the data until the processor doing so no longer errors. That does not seem to be what the O.P. was asking, though my interpretation may be wrong.

Error Handling Rollup to Main Procedure

If I have a main procedure with error handling that calls other procedures without error handling, should errors roll up to the main procedure?
What if the procedures without error handling use functions without error handling?
Should everything roll up to the main procedure's error handling?
Yes, unhandled errors will roll up the stack. If you have no error-handling in your main routine (or in the current event-handling routine), then the error will roll up to VBA itself, which will either cause your program to abort, or reset the VBA environment within the host applicaton. (you don't want that).
I can think of two apparent exceptions to this: one illusory and one real:
1) If VBA is entered through an unanticipated event-path, instead of though the main routine, it may appear that your Main-routines error-handler is being bypassed by the error-return, but in reality, it's another thread, so when it rolls-up from an event-handler, it goes to VBA independently of your Main routine's main-thread.
2) The VBA error-handling cannot catch ALL errors, in particular, most FATAL errors cannot be caught by it and crash (and reset) the whole VBA environment. "Stack Overflow" errors are an example.
Procedure A with error-handling will catch all errors. Procedure B with no error-handling will catch none.
If A calls B and B has an error, it will roll up and be caught in A's handler.
If B calls A and B has an error, there won't be any handling.
If B calls A and A has an error, A will catch it.
Whether it's a function or a procedure makes no difference. However it's worth noting that a class module won't handle errors locally, but passes them back up the stack to the first non-class module.
I'm not sure what you mean by "should," but where you want an error caught can depend on what you want to do with the error. For example, if a certain error requires you to make a small tweak on a string and then resume where you were, then you want very local handling. In other cases, simplicity might call for top-level handling.
Errors not locally handled will always* get trapped by the up-the-stack error handler if the error trapping option is set to "Break on Unhandled Errors". You'll find this setting in the IDE under Tools Options.
If it's set to "Break on All Errors", no error handler (neither local or up-the-stack) will be called. If it's set to "Break in Class Module", no out-of-class error handler will be called for in-class error.
Note that this option change the line on which the debugger stops: when an unhandled error occurs in a class module, the debugger stops on the line calling the class with "Break on Unhandled Errors" or on the offending line in the class with "Break in Class Module".
In Access, this option can be read programmatically with Application.GetOption("Error Trapping") and Application.SetOption("Error Trapping").
*As RBarryYoung has written, the most fatal errors (like stack overflow errors) won't be caught by any VBA error-handling.

Error Handling in Classic Asp without timeout error

In classic asp page, i need to catch the error description and insert into a table in the database.
when i use 'on error resume next', i am getting a timeout error as follows:
The maximum amount of time for a
script to execute was exceeded. You
can change this limit by specifying a
new value for the property
Server.ScriptTimeout or by changing
the value in the IIS administration
tools
Please help me to catch the exception and insert into database.
I believe your question is "How do I trap the Script Timeout error and record it in the database". Then the answer is you can't do it with On error resume next.
The problem is that ASP has determined your script has run for too long. In order for your code to trap and record the error your code needs to continue but that is exactly what ASP has determined shouldn't happen since its time is up.
Also in general unless you can continue to do something sensible (and that does not include logging) in your script there is no point trying to use On Error Resume Next to trap the error.
Instead create a new ASP script that should run whenever you get a script error (this will include a Script timeout error). In IIS manager open your applications property dialog and select the Custom Errors tab. Edit the handler for the 500;100 HTTP error and change it to URL and the path of this ASP script.
Now you can place your error logging code in this ASP script. You can access the error thrown by the failing ASP page by accessing the Server.GetLastError method. You can also configure this page to send something friendly to the user.
If the exception is with anything to do with your database you might have found your answer... have you checked to see what the problem is first?
Why not investigate/fix the timeout issue rather than try and catch the exception? Whilst you should log errors you should also investigate why it is occuring in the first place.