libhpdftbl 1.5.0
Table construction library for Haru PDF library
Loading...
Searching...
No Matches
hpdftbl_errstr.c File Reference

Utility module to translate HPDF error codes to human readable strings. More...

#include <stdio.h>
#include <hpdf.h>
#include "hpdftbl.h"

Data Structures

struct  hpdftbl_errcode_entry
 An entry in the error string table. More...
 

Macros

#define ERR_UNKNOWN   11
 Error code for unknown error.
 

Functions

const char * hpdftbl_hpdf_get_errstr (const HPDF_STATUS err_code)
 Function to return a human readable error string for an error code from Core HPDF library. More...
 
const char * hpdftbl_get_errstr (int err)
 Translate a table error code to a human readable string. More...
 
void hpdftbl_default_table_error_handler (hpdftbl_t t, int r, int c, int err)
 A basic default table error handler. More...
 
int hpdftbl_get_last_errcode (const char **errstr, int *row, int *col)
 Return last error code. More...
 
void hpdftbl_get_last_err_file (int *lineno, char **file, char **extrainfo)
 Get the filename and line number where the last error occurred. More...
 
hpdftbl_error_handler_t hpdftbl_set_errhandler (hpdftbl_error_handler_t err_handler)
 Specify errhandler for the table routines. More...
 

Variables

int hpdftbl_err_code = 0
 Stores the last generated error code. More...
 
int hpdftbl_err_row = -1
 The row where the last error was generated.
More...
 
int hpdftbl_err_col = -1
 The column where the last error was generated.
More...
 
int hpdftbl_err_lineno = 0
 Hold the line number of the last error occurred. More...
 
char * hpdftbl_err_file = NULL
 Hold the file name where the last error occurred. More...
 
char hpdftbl_err_extrainfo [1024] = {0}
 Extra info that may be specified at the point of error. More...
 

Detailed Description

Utility module to translate HPDF error codes to human readable strings.

Function Documentation

◆ hpdftbl_default_table_error_handler()

void hpdftbl_default_table_error_handler ( hpdftbl_t  t,
int  r,
int  c,
int  err 
)

A basic default table error handler.

This error handler is used as a callback that outputs the error to stderr in human readable format and quits the process.

Parameters
tTable where the error happened (can be NULL)
rCell row
cCell column
errThe error code
See also
hpdftbl_set_errhandler()

◆ hpdftbl_get_errstr()

const char * hpdftbl_get_errstr ( int  err)

Translate a table error code to a human readable string.

The function returns a pointer to a static string that cannot be modified. It will translate both internal table error messages as well as generic HPDF library error codes.

Parameters
errThe error code to be translated
Returns
Static pointer to string for valid error code, NULL otherwise
See also
hpdftbl_hpdf_get_errstr()

Referenced by hpdftbl_default_table_error_handler(), and hpdftbl_get_last_errcode().

◆ hpdftbl_get_last_err_file()

void hpdftbl_get_last_err_file ( int *  lineno,
char **  file,
char **  extrainfo 
)

Get the filename and line number where the last error occurred.

Parameters
linenoSet to the line number where the error occurred
fileSet to the file where the error occurred
extrainfoExtra info string that may be set at the point of error

◆ hpdftbl_get_last_errcode()

int hpdftbl_get_last_errcode ( const char **  errstr,
int *  row,
int *  col 
)

Return last error code.

Return last error code. if errstr is not NULL a human readable string describing the error will be copied to the string. The error code will be reset after call.

Parameters
errstrA string buffer where the error string is written to
rowThe row where the error was found
colThe col where the error was found
Returns
The last error code

◆ hpdftbl_hpdf_get_errstr()

const char * hpdftbl_hpdf_get_errstr ( const HPDF_STATUS  err_code)

Function to return a human readable error string for an error code from Core HPDF library.

The various error codes given by the HPDF library can be translated back to a string by the usage of this function. The function will return a pointer to a static string that can not be manipulated.

Parameters
err_codeThe error code
Returns
A pointer to an error string, NULL if the error code is invalid
See also
hpdftbl_get_errstr()

Referenced by hpdftbl_get_errstr().

◆ hpdftbl_set_errhandler()

hpdftbl_error_handler_t hpdftbl_set_errhandler ( hpdftbl_error_handler_t  err_handler)

Specify errhandler for the table routines.

Note: The library provides a basic default error handler that can be used,

Parameters
err_handler
Returns
The old error handler or NULL if non exists
See also
hpdftbl_default_table_error_handler()

Variable Documentation

◆ hpdftbl_err_code

int hpdftbl_err_code = 0

Stores the last generated error code.

Internal variable to record last error

Referenced by hpdftbl_get_errstr(), and hpdftbl_get_last_errcode().

◆ hpdftbl_err_col

int hpdftbl_err_col = -1

The column where the last error was generated.

Internal variable to record last error

Referenced by hpdftbl_get_last_errcode().

◆ hpdftbl_err_extrainfo

char hpdftbl_err_extrainfo[1024] = {0}

Extra info that may be specified at the point of error.

Internal variable to record last error

Referenced by hpdftbl_get_last_err_file().

◆ hpdftbl_err_file

char* hpdftbl_err_file = NULL

Hold the file name where the last error occurred.

Internal variable to record last error

Referenced by hpdftbl_get_last_err_file().

◆ hpdftbl_err_lineno

int hpdftbl_err_lineno = 0

Hold the line number of the last error occurred.

Internal variable to record last error

Referenced by hpdftbl_get_last_err_file().

◆ hpdftbl_err_row

int hpdftbl_err_row = -1

The row where the last error was generated.

Internal variable to record last error

Referenced by hpdftbl_get_last_errcode().