current stable:
cvs (0.99.7)
  Home / News
  The Team

  Source Tarball
  CVS Web View
  Misc. Files

The Manual
  Download [html]
  Download [pdf]
  View Online
  Download [html]
  View Online
  Script Examples

Developer Guide
  Download [html]
  Download [pdf]
  View Online
Ferite C API
  Download [html]
  View Online

Open Source Approved

SourceForge Logo - browse the Keyword Map of

[previous] Calling Functions[up][toc]Executing Code Snippets [next]

Raising Exceptions and Reporting Errors

There are times when things go wrong. It's a painful time, but it need not be. Ferite provides a means of raising exceptions to force a programmer to deal with errors but also a means of quietly setting the error information allowing the programmer to check for non-fatal things.

It is considered good form to return error values from a function call. This is the route you should take if you require the reporting of errors. For instance if you have a function that connects to a resource and returns an object to interact with that resource, it makes sense to return a null object [FE_RETURN_NULL_OBJECT] if that resource cant be obtained.

Sometimes this is not possible to return an error value. In these situations it is considered good form to use the function ferite_set_error [it's prototype is below]. This sets the err script object's values, but does not raise an exception. This allows the programmer to ignore things if needs be. It takes a number of parameters, the first is the script you are running in, the second is the error number and the last is the format of a string [same as printf] describing the error that has occured. It should be documented that this is the case such that the programmer knows what to look for.

    void ferite_set_error( FeriteScript *script, int num, char *fmt, ... );

When all hope is lost, there are times when an exception needs to be rasied because some has gone completely wrong. This is done by calling ferite_error. You can pass it the error number and the message just like ferite_set_error.

    void ferite_error( FeriteScript *script, int num, char *fmt, ... );

Sometimes it is nice to warn people about not so bad things, and as such there is a function ferite_warning which will place a warning on the script.

    void ferite_warning( FeriteScript *script, char *errormsg, ... );

[previous] Calling Functions[up][toc]Executing Code Snippets [next]
ferite et al © 2000-2004, Chris Ross