Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create errors.h for error diagnostics #29

Open
alecjohnson opened this issue Jul 15, 2013 · 0 comments
Open

Create errors.h for error diagnostics #29

alecjohnson opened this issue Jul 15, 2013 · 0 comments

Comments

@alecjohnson
Copy link
Contributor

I want to check in two groups of error diagnostics methods, to be accessed via

  #include "errors.h"

Firstly, a generic error message utility:

  eprintf(char*, varargs);

This prints file, line number, function, and the error message, and then exits. Similarly, a generic warning utility:

  Wprintf(char*, varargs);

Secondly, a generic utility to use when no case is selected:

  invalid_value_error(int);
  invalid_value_error(char *);
  invalid_value_error(double);

and

  unsupported_value_error(int);
  unsupported_value_error(char *);
  unsupported_value_error(double);

The most typical use is in the default clause of a switch statement. For example, in a routine to compute based on the number of dimensions :

    switch(ndims)
    {
        default: unsupported_value_error(ndims);
        case 2: b2=1-mbc; s2=S2+2*mbc;
        case 1: b1=1-mbc; s1=S1+2*mbc;
        case 0: ;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant