Documentation Center

  • Trial Software
  • Product Updates

sbiolasterror

SimBiology last error message

Syntax

sbiolasterror
diagstruct = sbiolasterror
sbiolasterror([])
sbiolasterror(diagstruct)

Arguments

diagstructThe diagnostic structure holding Type, Message ID, and Message for the errors.

Description

sbiolasterror or diagstruct = sbiolasterror return a SimBiology® diagnostic structure array containing the last error(s) generated by the software. The fields of the diagnostic structure are:

Type'error'
MessageID The message ID for the error (for example, 'SimBiology:ConfigSetNameClash')
Message The error message

sbiolasterror([]) resets the SimBiology last error so that it will return an empty array until the next SimBiology error is encountered.

sbiolasterror(diagstruct) will set the SimBiology last error(s) to those specified in the diagnostic structure (diagstruct).

Examples

This example shows how to use verify and sbiolasterror.

  1. Import a model.

      a = sbmlimport('radiodecay.xml')
      SimBiology Model - RadioactiveDecay 
    
       Model Components:
         Models:            0
         Parameters:        1
         Reactions:         1
         Rules:             0
         Species:           2
    
  2. Change the ReactionRate of a reaction to make the model invalid.

      a.reactions(1).reactionrate = 'x*y'
    
      SimBiology Model - RadioactiveDecay 
    
       Model Components:
         Models:            0
         Parameters:        1
         Reactions:         1
         Rules:             0
         Species:           2
    
  3. Use the function verify to validate the model.

      a.verify
    
    ??? Error using==>simbio\private\odebuilder>buildPatternSubStrings
    The object y does not resolve on reaction with expression'x*y'.
      
    Error in ==> sbiogate at 22
    feval(varargin{:});
      
    ??? --> Error reported from Expression Validation : 
    The object 'y' in reaction 'Reaction1' does not resolve
    to any in-scope species or parameters.
    --> Error reported from Dimensional Analysis : 
    Could not resolve species, parameter or model object 'y' 
    during dimensional analysis.
    --> Error reported from ODE Compilation:
    Error using==>simbio\private\odebuilder>buildPatternSubStrings
    The object y does not resolve on reaction with expression 'x*y'.
  4. Retrieve the error diagnostic struct.

      p = sbiolasterror
      p = 
    
      1x3 struct array with fields:
        Type
        MessageID
        Message
  5. Display the first error ID and Message.

    p(1)
    ans = 
    
         Type: 'Error'
    MessageID: 'SimBiology:ReactionObjectDoesNotResolve'
      Message: 'The object 'y' in reaction 'Reaction1' 
    							does not resolve to any in-scope 
    							species or parameters.'
  6. Reset the sbiolasterror.

    sbiolasterror([])
    
    
    ans =
    
         []
  7. Set sbiolasterror to the diagnostic struct.

sbiolasterror(p)


ans = 

1x3 struct array with fields:
    Type
    MessageID
    Message

More About

See Also

|

Was this topic helpful?