Changeset e6a122 for pcp/src


Ignore:
Timestamp:
Apr 21, 2008, 2:19:24 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
f2ce71c
Parents:
36f85c
git-author:
Frederik Heber <heber@…> (04/18/08 15:25:05)
git-committer:
Frederik Heber <heber@…> (04/21/08 14:19:24)
Message:

Error(): Idea and code taken from TREMOLO, now prints line number and sourc file name

Location:
pcp/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/errors.c

    r36f85c re6a122  
    3131 * \param *SpecialData is a typeless pointer on special data for error treatment, here detailed error message.
    3232*/
    33 void Error(enum Errors error, const void *SpecialData)
     33void Error_in(enum Errors error, const void *SpecialData,
     34    const char *file, const int line)
    3435{
    3536  const char *const error_msg[] = {
    3637    "SomeError",
    37     "FileOpenParams\nUnable to open parameter file",
     38    "FileOpenParams\nUnable to open parameter file\n",
    3839    "InitReading\n",
    39     "MallocError\nUnable to allocate memory!",
     40    "MallocError\nUnable to allocate memory!\n",
    4041  };
    4142  int mytid;
    4243  MPI_Comm_rank(MPI_COMM_WORLD, &mytid);
    4344  fprintf(stderr, "\nProcess %i: ", mytid);
    44   fprintf(stderr, "It has occured an error (%i): %s\n", error, error_msg[error]);
     45  fprintf(stderr, "Error in file %s, line %d (%i): %s - ",
     46      file, line, (int)error, error_msg[error]);
    4547  switch (error) {
    4648  case InitReading:
  • pcp/src/errors.h

    r36f85c re6a122  
    1616*/
    1717
     18// taken out of TREMOLO
     19/*@-namechecks@*/
     20#ifndef __GNUC__
     21# undef __attribute__
     22# define __attribute__(x)
     23#endif
     24/*@=namechecks@*/
    1825
    1926/* Verschiedene Fehlertypen */
     
    2532/* SomeError: Falls man noch zu faul ist */
    2633
     34
    2735/* Behandelt aufgetretene Fehler. error ist der Fehlertyp(enum Errors)
    2836   void *SpecialData ist ein untypisierter Zeiger auf Spezielle Daten zur Fehlerbehandlung.
    2937   Man koennte auch noch einen Zeiger auf eine Funktion uebergeben */
    30 void Error(enum Errors error, const void *SpecialData);
     38extern void /*@exits@*/ Error(enum Errors error, /*@null@*/ const void *SpecialData)
     39  __attribute__ ((__noreturn__));
     40#define Error(err, data) Error_in((err), (data), __FILE__, __LINE__)
     41
     42extern void /*@exits@*/ Error_in(enum Errors error, /*@null@*/ const void *SpecialData,
     43    const char *file, const int line)
     44  __attribute__ ((__noreturn__));
    3145
    3246#endif
Note: See TracChangeset for help on using the changeset viewer.