lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

error.h (673B)


      1 
      2 #ifndef LNSOCKET_ERROR_H
      3 #define LNSOCKET_ERROR_H
      4 
      5 #include "cursor.h"
      6 
      7 struct error {
      8 	const char *msg;
      9 };
     10 
     11 struct errors {
     12 	struct cursor cur;
     13 	int enabled;
     14 };
     15 
     16 #define note_error(errs, fmt, ...) note_error_(errs, "%s:%s:%d: " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
     17 
     18 static inline int cursor_push_error(struct cursor *cur, struct error *err)
     19 {
     20 	return cursor_push_c_str(cur, err->msg);
     21 }
     22 
     23 static inline int cursor_pull_error(struct cursor *cur, struct error *err)
     24 {
     25 	return cursor_pull_c_str(cur, &err->msg);
     26 }
     27 
     28 int note_error_(struct errors *errs, const char *fmt, ...);
     29 
     30 void print_error_backtrace(struct errors *errors);
     31 
     32 #endif /* LNSOCKET_ERROR_H */