developer:sequencer:exception_handling
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| developer:sequencer:exception_handling [2015/02/10 17:22] – external edit 127.0.0.1 | developer:sequencer:exception_handling [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Error Handler Usage====== | ||
| - | The error handler is also a sequence. But it will be used in case of an exception, so the user knows that it is a recovery pass. | ||
| - | To create a new error handler, you have to derive from the class // | ||
| - | |||
| - | <code c> | ||
| - | class MyErrorHandlerA : public eeros:: | ||
| - | </ | ||
| - | Then you can implement the //run()// methode including all the functionality to solve the problem causing the exception or to restart the system. | ||
| - | |||
| - | <code c> | ||
| - | void MyErrorHandlerA:: | ||
| - | Reset(); | ||
| - | Referencing(); | ||
| - | RestartSequence(); | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | This //run()// methode will be called in the base class // | ||
| - | e.g.: | ||
| - | |||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | The constructor has following parameters: | ||
| - | |||
| - | <code c> | ||
| - | SequenceException(Sequence* seqCause, Sequence:: | ||
| - | ErrorHandler* error, bool toBegin, bool goToNext, std::string reason); | ||
| - | </ | ||
| - | __Parameter // | ||
| - | |||
| - | __Parameter //next//:__ If //toBegin// is false and // | ||
| - | |||
| - | __Parameter // | ||
| - | Please note: //toBegin// and // | ||
| - | |||
| - | __Parameter // | ||
| - | |||
| - | __Parameter // | ||
| - | |||
| - | __Parameter reason:__ error message | ||
| - | |||
| - | =====Case 1===== | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | =====Case 2===== | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | =====Case 3===== | ||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | The // | ||
| - | |||
| - | <code c> | ||
| - | MyErrorHandlerB* errorHandlerB = | ||
| - | dynamic_cast< | ||
| - | if(!errorHandlerB){ | ||
| - | errorHandlerB = new MyErrorHandlerB(" | ||
| - | } | ||
| - | errorHandlerB-> | ||
| - | </ | ||
| - | |||
| - | =====Case 4===== | ||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | |||
| - | </ | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | =====Case 5===== | ||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | In the case, which the sequencer will be restarted on an exception, the sub-sequencer could be kept on running state or it could also be restarted. This can be choosen by the user. | ||
| - | The code below shows how you can solve it. | ||
| - | |||
| - | <code c> | ||
| - | MySequencer* subSequencer = dynamic_cast< | ||
| - | (eeros:: | ||
| - | bool seqIsNew = false; | ||
| - | if(!subSequencer){ | ||
| - | //use pointer to leave the object in memory!! | ||
| - | //without pointer the objetct will be destroyed. | ||
| - | subSequencer = new MySequencer(" | ||
| - | seqIsNew = true; | ||
| - | // | ||
| - | //please take attention, if this Object looses scope, so it will be deleted!! | ||
| - | // | ||
| - | //else the pointer in the Executor runnables list of the Sequencer will point to nowhere!! | ||
| - | } | ||
| - | NonBlockingSubSequence* subSequence = dynamic_cast< | ||
| - | (eeros:: | ||
| - | if(!subSequence){ | ||
| - | // | ||
| - | subSequence = new NonBlockingSubSequence(" | ||
| - | if(seqIsNew){ | ||
| - | //now we start the Thread of the subSequencer | ||
| - | subSequencer-> | ||
| - | } | ||
| - | } | ||
| - | try{ | ||
| - | if(!seqIsNew && restartSequencer && subSequencer && | ||
| - | subSequencer-> | ||
| - | eeros:: | ||
| - | subSequencer-> | ||
| - | } | ||
| - | |||
| - | }catch(char *str){ | ||
| - | |||
| - | } | ||
| - | </ | ||
| - | |||
| - | If restartSequencer is true, so the sub-sequencer will be restarted | ||
| - | |||
| - | If restartSequencer is false, so the sub-sequencer runs until he finished, without restarting. | ||
| - | |||
| - | =====Case 6===== | ||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | |||
| - | </ | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | =====Case 7===== | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | =====Case 8===== | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
| - | |||
| - | [{{ : | ||
| - | |||
| - | exception: | ||
| - | <code c> | ||
| - | throw new eeros:: | ||
| - | static_cast< | ||
| - | static_cast< | ||
| - | errorHandlerA, | ||
| - | </ | ||
developer/sequencer/exception_handling.1423585326.txt.gz · Last modified: 2015/02/10 17:37 (external edit)