Menu

#611 Create a try-catch statement

v1.1.x
closed
v1.1.4
New Functionality
2022-01-19
2021-07-27
Erik Hänel
No

Create a try-catch statement, which can be used to catch errors. Something like

try
## some code
catch (ERRORTYPE)
## handle here
catch (OTHER ERROR TYPE)
## handle here
endtry

Analysis:

The try-catch statement can be implemented as flow ctrl statement with some logical adaptions. Furthermore, we'll have to select the error types, which can be catched by this statement. As syntax, we'll use

try
     ## some code
catch expression:  ## catch errors of type "expression" here
     ## handle these errors
catch:  ## catch all other catchable errors here
     {sType, sMessage} = getlasterror(); ## Get type and message
     warn sMessage  ## do something with the information
     rethrow;  ## rethrow the handled error
endtry

Implementation:

  • Implementation: Implemented as proposed by the analysis.
  • Revision: [r1018] and [r1019]
  • Implementation test: Code segments with try...catch , getlasterror() and rethrow were executed.

Documentation:

  • ChangesLog updated
  • Code changes commented
  • Documentation articles:
    • corresponding documentation articles updated
    • new documentation articles created
    • not needed
  • Language files:
    • corresponding language files updated
    • not needed

Tests:

Functionality was added to the automatic SW tests. No deviations detected.

Related

Commit: [r1018]
Commit: [r1019]
Tickets: #600

Discussion

  • Erik Hänel

    Erik Hänel - 2021-08-18
    • labels: --> internal, ctrlflow, procedure
     
  • Erik Hänel

    Erik Hänel - 2021-09-23
    • status: open --> accepted
     
  • Erik Hänel

    Erik Hänel - 2021-09-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -7,3 +7,25 @@
         catch (OTHER ERROR TYPE)
         ## handle here
         endtry
    +    
    +###Analysis:
    +(*Describe, what's the issue and which changes have to be made*)
    +
    +###Implementation:
    +* Implementation: (*Describe, what you've changed*) 
    +* Revision: [rXXX]
    +* Implementation test: (*Describe the type of test, which you performed, and if it was successful*)
    +
    +###Documentation:
    +* [ ] ChangesLog updated
    +* [ ] Code changes commented
    +* **Documentation articles:**
    +    * [ ] corresponding documentation articles updated
    +    * [ ] new documentation articles created
    +    * [ ] not needed
    +* **Language files:**
    +    * [ ] corresponding language files updated
    +    * [ ] not needed
    +
    +###Tests:
    +(*Describe, which tests you performed and their outcome*)
    
    • status: accepted --> analyzing
     
  • Erik Hänel

    Erik Hänel - 2021-09-30
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -9,7 +9,18 @@
         endtry
    
     ###Analysis:
    -(*Describe, what's the issue and which changes have to be made*)
    +The `try-catch`  statement can be implemented as flow ctrl statement with some logical adaptions. Furthermore, we'll have to select the error types, which can be catched by this statement. As syntax, we'll use
    +
    +    :::matlab
    +    try
    +         ## some code
    +    catch expression:  ## catch errors of type "expression" here
    +         ## handle these errors
    +    catch:  ## catch all other catchable errors here
    +         {sType, sMessage} = getlasterror(); ## Get type and message
    +         warn sMessage  ## do something with the information
    +         rethrow;  ## rethrow the handled error
    +    endtry
    
     ###Implementation:
     * Implementation: (*Describe, what you've changed*) 
    
    • status: analyzing --> implementing
     
  • Erik Hänel

    Erik Hänel - 2021-10-01
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -23,19 +23,19 @@
         endtry
    
     ###Implementation:
    -* Implementation: (*Describe, what you've changed*) 
    -* Revision: [rXXX]
    -* Implementation test: (*Describe the type of test, which you performed, and if it was successful*)
    +* Implementation: Implemented as proposed by the analysis.
    +* Revision: [r1018] and [r1019]
    +* Implementation test: Code segments with `try...catch` , `getlasterror()` and `rethrow` were executed.
    
     ###Documentation:
    -* [ ] ChangesLog updated
    -* [ ] Code changes commented
    +* [x] ChangesLog updated
    +* [x] Code changes commented
     * **Documentation articles:**
         * [ ] corresponding documentation articles updated
    -    * [ ] new documentation articles created
    +    * [x] new documentation articles created
         * [ ] not needed
     * **Language files:**
    -    * [ ] corresponding language files updated
    +    * [x] corresponding language files updated
         * [ ] not needed
    
     ###Tests:
    
    • status: implementing --> testing
     

    Related

    Commit: [r1018]
    Commit: [r1019]

  • Erik Hänel

    Erik Hänel - 2022-01-19
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -39,4 +39,4 @@
         * [ ] not needed
    
     ###Tests:
    -(*Describe, which tests you performed and their outcome*)
    +Functionality was added to the automatic SW tests. No deviations detected.
    
    • status: testing --> closed
     

Anonymous
Anonymous

Add attachments
Cancel