[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Error Handling

The functions in EB Library set the global variable eb_error, when they fail to accomplish a job. The variable eb_error stores an error code of the last error raised in EB Library functions.

EB Library has error messages for all error codes. eb_error_message() returns the error messages according to the current value of eb_error.

 
fprintf(stderr, "failed to bind a book, %s\n", eb_error_message());

If eb_error has been set to EB_ERR_TOO_LONG_FILENAME, it outputs the following error message.

 
failed to bind a book, too long filename.

4.1 Tolerance to Error  
4.2 Data Types  
4.3 Global Variables  
4.4 Functions  
4.5 Error Codes  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Tolerance to Error

An EB_Book object has some state parameters. Also whether the object is bound to a CD-ROM book or not is one of the paramters. Some of the functions which take a pointer to an EB_Book object as an argument expect that a certain parameter of the referred object has been set beforehand. For example, eb_path() expects that the object is bound.

What's happen if do you give the unbound object to eb_path()?

 
EB_Book book;

eb_initialize(&book);
eb_path(&book);        /* What's happen? */

In this case, eb_path() returns NULL and sets eb_error to EB_ERR_UNBOUND_BOOK. Thus, EB library functions precisely reject objects whose required parameter is not set.

However, the follwoing action makes your program abort.

 
eb_path(NULL);    /* abort! */

EB Library functions doesn't inspect whether a pointer given as an argument is NULL, unless the function description says that it accepts NULL.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Data Types

Please include `eb/error.h' to use the data types described in this section:

 
#include <eb/error.h>

Data type: EB_Error_Code

The EB_Error_Code type represents an error code defined in EB Library. EB Library defines EB_NUM_ERRORS error types. This type is defined from a signed integral type, so that you can compare two codes by the == and != binomial operators.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Global Variables

Please include `eb/error.h' to set and/or refer the variables described in this section:

 
#include <eb/error.h>

Variable: EB_Error_Code eb_error

The functions in EB Library set the global variable eb_error, when the function fails to accomplish a job. The variable eb_error stores an error code of the last error raised in EB Library functions.

The library functions never clears this variable, even when a job is accomplished without an error. eb_error stores the latest error only. When another error occurs, the library functions ovewrite this variable. Also you may overwrite the variable in your program.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Functions

Please include `eb/error.h' to use the functions described in this section:

 
#include <eb/error.h>

Function: const char * eb_error_message (void)

The function eb_error_message() returns the error message according to the current value of eb_error. If eb_error is set to a valid error-code, it returns the corresponding error message. Otherwise, it returns the string "unknown error". The maximum length of the message is EB_MAXLEN_ERROR_MESSAGE. This function never changes the value of eb_error.

Function: const char * eb_error_message2 (EB_Error_Code code)

The function eb_error_message2() returns the error message according to the error code code. If code represents a valid error-code, it returns the corresponding error message. Otherwise, it returns the string "unknown error". The maximum length of the message is EB_MAXLEN_ERROR_MESSAGE. This function never changes the value of eb_error.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Error Codes

EB Library defines the following error codes. Please include `eb/error.h' to use the error codes.

 
#include <eb/error.h>

Constant: EB_NO_ERR

No error occured.

Constant: EB_ERR_MEMORY_EXHAUSTED

EB Library invoked malloc(), but NULL was returned.

Constant: EB_ERR_EMPTY_FILENAME

This error code is obsoleted.

Constant: EB_ERR_TOO_LONG_FILENAME

eb_bind() or eb_bind_appendix() failed because the given filename was too long.

Constant: EB_ERR_TOO_LONG_WORD

eb_search_word(), eb_search_endword() or eb_search_exactword() failed because the given word was too long.

Constant: EB_ERR_BAD_WORD

eb_search_word(), eb_search_endword() or eb_search_exactword() failed because the given word had an invalid character.

Constant: EB_ERR_EMPTY_WORD

eb_search_word(), eb_search_endword() or eb_search_exactword() failed because the given word was empty.

Constant: EB_ERR_FAIL_GETCWD

getcwd() or getwd() failed.

Constant: EB_ERR_FAIL_OPEN_CAT

EB Library failed to open a `CATALOG' or `CATALOGS' file in a book.

Constant: EB_ERR_FAIL_OPEN_CATAPP

EB Library failed to open a `CATALOG' or `CATALOGS' file in an appendix.

Constant: EB_ERR_FAIL_OPEN_LANG

EB Library failed to open a `LANGUAGE' file in a book.

Constant: EB_ERR_FAIL_OPEN_START

EB Library failed to open a `START' or `HONMON' file in a book.

Constant: EB_ERR_FAIL_OPEN_FONT

EB Library failed to open a font file (files at `GAIJI' directory) in a book.

Constant: EB_ERR_FAIL_OPEN_APP

EB Library failed to open an `APPENDIX' or `FUROKU' file in an appendix.

Constant: EB_ERR_FAIL_READ_CAT

EB Library failed to read a `CATALOG' or `CATALOGS' file in an book.

Constant: EB_ERR_FAIL_READ_CATAPP

EB Library failed to read a `CATALOG' or `CATALOGS' file in an appendix.

Constant: EB_ERR_FAIL_READ_LANG

EB Library failed to read a `LANGUAGE' file in a book.

Constant: EB_ERR_FAIL_READ_START

EB Library failed to read a `START' or `HONMON' file in a book.

Constant: EB_ERR_FAIL_READ_FONT

EB Library failed to read a font file (files at `GAIJI' directory) in a book.

Constant: EB_ERR_FAIL_READ_APP

EB Library failed to read an `APPENDIX' or `FUROKU' file in an appendix.

Constant: EB_ERR_FAIL_SEEK_CAT

EB Library failed to seek a `CATALOG' or `CATALOGS' file in an book.

Constant: EB_ERR_FAIL_SEEK_CATAPP

EB Library failed to seek a `CATALOG' or `CATALOGS' file in an appendix.

Constant: EB_ERR_FAIL_SEEK_LANG

EB Library failed to seek a `LANGUAGE' file in a book.

Constant: EB_ERR_FAIL_SEEK_START

EB Library failed to seek a `START' or `HONMON' file in a book.

Constant: EB_ERR_FAIL_SEEK_FONT

EB Library failed to seek a font file (files at `GAIJI' directory) in a book.

Constant: EB_ERR_FAIL_SEEK_APP

EB Library failed to seek an `APPENDIX' or `FUROKU' file in an appendix.

Constant: EB_ERR_UNEXP_CAT

EB Library happened to meet an unexpected data in a `CATALOG' or `CATALOGS' file in a book.

Constant: EB_ERR_UNEXP_CATAPP

EB Library happened to meet an unexpected data in a `CATALOG' or `CATALOGS' file in an appendix.

Constant: EB_ERR_UNEXP_LANG

EB Library happened to meet an unexpected data in a `LANGUAGE' file in a book.

Constant: EB_ERR_UNEXP_START

EB Library happened to meet an unexpected data in a `START' or `HONMON' file in a book.

Constant: EB_ERR_UNEXP_FONT

EB Library happened to meet an unexpected data in a font file (files at `GAIJI' directory) in a book.

Constant: EB_ERR_UNEXP_APP

EB Library happened to meet an unexpected data in an `APPENDIX' or `FUROKU' file in an appendix.

Constant: EB_ERR_UNBOUND_BOOK

The invoked EB Library function requires a bound EB_Book object as an argument, but the given object was not bound.

Constant: EB_ERR_UNBOUND_APP

The invoked EB Library function requires a bound EB_Appendix object as an argument,but the given object was not bound.

Constant: EB_ERR_NO_LANG

The book had no language data.

Constant: EB_ERR_NO_SUB

The book had no subbook.

Constant: EB_ERR_NO_APPSUB

The appendix had no subbook.

Constant: EB_ERR_NO_MSG

The current language in a book had no message.

Constant: EB_ERR_NO_FONT

The current subbook in a book had no font.

Constant: EB_ERR_NO_START

The current subbook in a book didn't have a `START' nor `HONMON' file.

Constant: EB_ERR_NO_CUR_LANG

The invoked function requires that an EB_Book object given as an argument had set the current language, but the given book didn't not set it.

Constant: EB_ERR_NO_CUR_SUB

The invoked function requires that an EB_Book object given as an argument had set the current subbook, but the given book didn't set it.

Constant: EB_ERR_NO_CUR_APPSUB

The invoked function requires that an appendix given as an argument had set the current subbook, but the given appendix didn't set it.

Constant: EB_ERR_NO_CUR_FONT

The invoked function requires that an EB_Book object given as an argument had set the current font height, but the given book didn't set it.

Constant: EB_ERR_NO_SUCH_LANG

An EB_Book object and a language code were given to a function, but the bound book didn't have the language with the code.

Constant: EB_ERR_NO_SUCH_SUB

An EB_Book object and a subbook code were given to a function, but the bound book didn't have the subbook with the code.

Constant: EB_ERR_NO_SUCH_APPSUB

An EB_Appendix object and a subbook code were given to a function, but the bound appendix didn't have the subbook with the code.

Constant: EB_ERR_NO_SUCH_MSG

An EB_Book object and a message code were given to a function, but the currnet language of the bound book the object didn't have the message with the code.

Constant: EB_ERR_NO_SUCH_FONT

An EB_Book object and a font ehgiht were given to a function, but the currnet subbook of the bound book didn't have the font with the height.

Constant: EB_ERR_NO_SUCH_CHAR_BMP

An EB_Book object and a character number was given to a function, but the current subbook of the bound book didn't have bitmap data of the character number.

Constant: EB_ERR_NO_SUCH_CHAR_TEXT

An EB_Appendix object and a character number was given to a function, but the current subbook of the bound appendix didn't have an alternation string of the character number.

Constant: EB_ERR_NO_SUCH_SEARCH

eb_search_word(), eb_search_endword() or eb_search_exactword() failed because the book didn't support the search method.

Constant: EB_ERR_NO_SUCH_HOOK

An invalid hook code was given to a function.

Constant: EB_ERR_HOOK_WORKSPACE

An hook function returned -1.

Constant: EB_ERR_DIFF_CONTENT

A continuation of getting text contetns was requested, but the content type was different from that given at the previous call.

Constant: EB_ERR_DIFF_SUBBOOK

The EB_Book object was given to eb_hit_list(), eb_heading(), eb_rawtext() or eb_text(), but the current subbook was different from that given at the previous call.

Constant: EB_ERR_DIFF_BOOK

The EB_Book object was given to eb_hit_list(), eb_heading(), eb_rawtext() or eb_text(), but the object was different from that given at the previous call.

Constant: EB_ERR_NO_PREV_SEARCH

You invoked eb_hit_list(), but you had not invoked eb_search_word(), eb_search_endword() nor eb_search_exactword() beforehand.

Constant: EB_ERR_NO_PREV_CONTENT

You invoked eb_text(), eb_heading() or eb_rawtext() but you had not invoked eb_seek() beforehand.

Constant: EB_ERR_NO_SUCH_MULTI_ID

An EB_Book object and a multi search code was given to a function, but the current subbook of the bound book didn't have a multi search with the code.

Constant: EB_ERR_NO_SUCH_ENTRY_ID

An EB_Book object and a mulit search entry code was given to a function, but the current subbook of the bound book didn't have a multi search entry with the code.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Motoyuki Kasahara on July, 7 2000 using texi2html