1 /* error.h                                         -*- mode:c; coding:utf-8; -*-
2  *
3  *   Copyright (c) 2010-2021  Takashi Kato <ktakashi@ymail.com>
4  *
5  *   Redistribution and use in source and binary forms, with or without
6  *   modification, are permitted provided that the following conditions
7  *   are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *
16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *  $Id: $
29  */
30 #ifndef SAGITTARIUS_PRIVATE_ERROR_H_
31 #define SAGITTARIUS_PRIVATE_ERROR_H_
32 
33 #include "sagittariusdefs.h"
34 
35 typedef enum {
36   SG_IO_READ_ERROR,
37   SG_IO_WRITE_ERROR,
38   SG_IO_FILE_NOT_EXIST_ERROR,
39   SG_IO_FILE_ALREADY_EXIST_ERROR,
40   SG_IO_DECODE_ERROR,
41   SG_IO_ENCODE_ERROR,
42   SG_IO_FILENAME_ERROR,
43   SG_IO_FILE_PROTECTION_ERROR,
44   SG_IO_UNKNOWN_ERROR = -1		/* for convenience */
45 } SgIOErrorType;
46 
47 SG_CDECL_BEGIN
48 
49 SG_EXTERN void Sg_Warn(const SgChar* msg, ...);
50 SG_EXTERN void Sg_Error(const SgChar* msg, ...);
51 SG_EXTERN void Sg_ReadError(const SgChar* msg, ...);
52 SG_EXTERN void Sg_SystemError(int errono, const SgChar* msg, ...);
53 SG_EXTERN void Sg_SyntaxError(SgObject form, SgObject irritants);
54 
55 /* general &i/o exception*/
56 SG_EXTERN void Sg_IOError(SgIOErrorType type, SgObject who, SgObject msg,
57 			  SgObject file, SgObject port);
58 SG_EXTERN void Sg_IOReadError(SgObject who, SgObject msg, SgObject port,
59 			      SgObject irr);
60 SG_EXTERN void Sg_IOWriteError(SgObject who, SgObject msg, SgObject port,
61 			       SgObject irr);
62 SG_EXTERN void Sg_IOFileDoesNotExistError(SgObject file, SgObject who,
63 					  SgObject msg);
64 SG_EXTERN void Sg_IOFileAlreadyExistsError(SgObject file, SgObject who,
65 				      SgObject msg);
66 SG_EXTERN void Sg_IODecodingError(SgObject port, SgObject who, SgObject msg);
67 SG_EXTERN void Sg_IOEncodingError(SgObject port, SgChar c, SgObject who,
68 				  SgObject msg);
69 SG_EXTERN void Sg_IOFilenameError(SgObject file, SgObject who, SgObject msg);
70 SG_EXTERN void Sg_IOFileProtectionError(SgObject file, SgObject who,
71 					SgObject msg);
72 
73 SG_EXTERN void Sg_AssertionViolation(SgObject who, SgObject message,
74 				     SgObject irritants);
75 SG_EXTERN void Sg_UndefinedViolation(SgObject who, SgObject message);
76 SG_EXTERN void Sg_ImplementationRestrictionViolation(SgObject who,
77 						     SgObject message,
78 						     SgObject irritants);
79 
80 /* these are for stub files */
81 SG_EXTERN void Sg_WrongTypeOfArgumentViolation(SgObject who,
82 					       SgObject requiredType,
83 					       SgObject gotValue,
84 					       SgObject irritants);
85 SG_EXTERN void Sg_WrongNumberOfArgumentsViolation(SgObject who,
86 						  int requiredCounts,
87 						  int gotCounts,
88 						  SgObject irritants);
89 SG_EXTERN void Sg_WrongNumberOfArgumentsAtLeastViolation(SgObject who,
90 							 int requiredCounts,
91 							 int gotCounts,
92 							 SgObject irritants);
93 SG_EXTERN void Sg_WrongNumberOfArgumentsBetweenViolation(SgObject who,
94 							 int startCounts,
95 							 int endCounts,
96 							 int gotCounts,
97 							 SgObject irritants);
98 
99 SG_EXTERN SgObject Sg_Raise(SgObject condition, int continuableP);
100 
101 SG_EXTERN SgIOErrorType Sg_ErrnoToIOErrorType(int e);
102 
103 SG_CDECL_END
104 
105 #endif /* SAGITTARIUS_ERROR_HPP_ */
106 
107 /*
108   end of file
109   Local Variables:
110   coding: utf-8-unix
111   End:
112 */
113