~ubuntu-branches/ubuntu/wily/libsereal-encoder-perl/wily

« back to all changes in this revision

Viewing changes to srl_error.h

  • Committer: Package Import Robot
  • Author(s): Alexandre Mestiashvili, Alexandre Mestiashvili, gregor herrmann
  • Date: 2015-04-29 11:12:18 UTC
  • mfrom: (17.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20150429111218-v3ghc7ck5gcr38fu
Tags: 3.005.001-1
[ Alexandre Mestiashvili ]
* Imported Upstream version 3.005.001
* d/control: cme fix dpkg
* d/copyright: updated debian/* copyright year

[ gregor herrmann ]
* Mark package as autopkgtest-able.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SRL_ERROR_H_
 
2
#define SRL_ERROR_H_
 
3
#include "srl_taginfo.h"
 
4
 
 
5
#define SRL_BASE_ERROR_FORMAT "Sereal: Error in %s line %u and char %i of input: "
 
6
#define SRL_BASE_ERROR_ARGS __FILE__, __LINE__, (int) (1 + dec->pos - dec->buf_start)
 
7
 
 
8
#define SRL_ERROR(msg)                          croak(SRL_BASE_ERROR_FORMAT "%s", SRL_BASE_ERROR_ARGS, (msg))
 
9
#define SRL_ERRORf1(fmt,var)                    croak(SRL_BASE_ERROR_FORMAT fmt,  SRL_BASE_ERROR_ARGS, (var))
 
10
#define SRL_ERRORf2(fmt,var1,var2)              croak(SRL_BASE_ERROR_FORMAT fmt,  SRL_BASE_ERROR_ARGS, (var1), (var2))
 
11
#define SRL_ERRORf3(fmt,var1,var2,var3)         croak(SRL_BASE_ERROR_FORMAT fmt,  SRL_BASE_ERROR_ARGS, (var1), (var2), (var3))
 
12
#define SRL_ERRORf4(fmt,var1,var2,var3,var4)    croak(SRL_BASE_ERROR_FORMAT fmt,  SRL_BASE_ERROR_ARGS, (var1), (var2), (var3), (var4))
 
13
 
 
14
#define SRL_ERROR_UNIMPLEMENTED(dec,tag,str) \
 
15
    SRL_ERRORf3("Tag %u %s is unimplemented at ofs: %lu", (tag), (str), (unsigned long) BUF_POS_OFS(dec))
 
16
 
 
17
#define SRL_ERROR_UNTERMINATED(dec,tag,str)                                                                 \
 
18
    SRL_ERRORf4("Tag SRL_HDR_%s %s was not terminated properly at ofs %lu with %lu to go",                  \
 
19
                tag_name[(tag) & 127], (str), (dec)->pos - (dec)->buf_start, (dec)->buf_end - (dec)->pos)
 
20
 
 
21
#define SRL_ERROR_BAD_COPY(dec, tag) \
 
22
    SRL_ERRORf1("While processing tag SRL_HDR_%s encountered a bad COPY tag", tag_name[(tag) & 127])
 
23
 
 
24
#define SRL_ERROR_UNEXPECTED(dec, tag, msg) SRL_ERRORf2("Unexpected tag %s while expecting %s", tag_name[(tag) & 127], msg)
 
25
#define SRL_ERROR_REFUSE_OBJECT()           SRL_ERROR("Encountered object in input, but the 'refuse_objects' option is in effect");
 
26
#define SRL_ERROR_PANIC(dec, msg)           SRL_ERRORf1("Panic: %s", msg);
 
27
 
 
28
#endif