Loading...
Searching...
No Matches
plumed_error Struct Reference

Small structure that is only defined locally to retrieve errors. More...

#include <Plumed.h>

Public Attributes

int code
 code used for translating messages
 
int error_category
 category - for errors
 
int error_code
 error code for system_error
 
struct plumed_errornested
 pointer to nested exception
 
plumed_error_filesystem_path path1
 path1 - for filesystem_error
 
plumed_error_filesystem_path path2
 path2 - for filesystem_error
 
const char * what
 message
 
char * what_buffer
 the buffer containing the message to be deallocated
 

Detailed Description

Small structure that is only defined locally to retrieve errors.

It is supposed to be used in the C11/C++ plumed_cmd interface as follows:

  plumed p;
  plumed_error error;

  p=plumed_create();

  plumed_cmd(p,"setNatoms",10,&error);
  if(error.code) {
    fprintf(errors,"%d\n",error.code);
    plumed_error_finalize(error); // make sure the error object is finalized!
  }
  // if no error was raised (error.code==0), it is not necessary to call plumed_error_finalize.
  // but doing it is harmless

  // no need to initialize error, it is written in the plumed_cmd function
  plumed_cmd(p,"init",&error);
  if(error.code) {
    fprintf(errors,"%d\n",error.code);
    plumed_error_finalize(error); // make sure the error object is finalized!
  }

The layout of this structure is subject to change, thus all the functions manipulating it are defined as inline/static functions. In the future, we might reach some form of ABI stability, and these functions might be moved below to the implementation file.

Notice that there is a macro plumed_error() defined in the PLUMED source code (at tools/Exception.h). There is no conflict with this type since C preprocessor distinguishes macros and function-like macros.

Member Data Documentation

◆ code

int plumed_error::code

code used for translating messages

◆ error_category

int plumed_error::error_category

category - for errors

◆ error_code

int plumed_error::error_code

error code for system_error

◆ nested

struct plumed_error* plumed_error::nested

pointer to nested exception

◆ path1

plumed_error_filesystem_path plumed_error::path1

path1 - for filesystem_error

◆ path2

plumed_error_filesystem_path plumed_error::path2

path2 - for filesystem_error

◆ what

const char* plumed_error::what

message

◆ what_buffer

char* plumed_error::what_buffer

the buffer containing the message to be deallocated


The documentation for this struct was generated from the following file: