File: err.h

package info (click to toggle)
ruby-ox 2.14.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,504 kB
  • sloc: xml: 39,683; ansic: 9,626; ruby: 6,441; sh: 47; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* err.h
 * Copyright (c) 2011, Peter Ohler
 * All rights reserved.
 */

#ifndef OX_ERR_H
#define OX_ERR_H

#include "ruby.h"

#define set_error(err, msg, xml, current) _ox_err_set_with_location(err, msg, xml, current, __FILE__, __LINE__)

typedef struct _err {
    VALUE clas;
    char  msg[128];
} *Err;

extern VALUE ox_arg_error_class;
extern VALUE ox_parse_error_class;
extern VALUE ox_syntax_error_class;

extern void ox_err_set(Err e, VALUE clas, const char *format, ...);
extern void
_ox_err_set_with_location(Err err, const char *msg, const char *xml, const char *current, const char *file, int line);
extern void ox_err_raise(Err e);

inline static void err_init(Err e) {
    e->clas = Qnil;
    *e->msg = '\0';
}

inline static int err_has(Err e) {
    return (Qnil != e->clas);
}

#endif /* OX_ERR_H */