/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Error.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-10-01 15:43:43 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20151001154343-y24virkewqp6p575
* Added discussion on SError and Error Pragagation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 */
45
45
typedef struct SErrorPrivate SErrorPrivate;
46
46
 
 
47
 
 
48
typedef void (* SErrorDomainToString)(sint error_id, schar * error_msg);
 
49
 
47
50
/**
48
51
 * An SError is a data structure that inherits from SBaseObjectInstance.
49
52
 * 
84
87
} SErrorType;
85
88
 
86
89
/**
87
 
 * @var static char * SErrorTypeName[] __attribute__((unused))
 
90
 * @var static char * SErrorTypeName[]
88
91
 * @breif
89
92
 * Holds the names of the string version of SErrorType.
90
93
 */
139
142
void
140
143
s_error_print_error (SError * self);
141
144
 
 
145
#if 0
 
146
TODO
 
147
##########
 
148
 
 
149
I have been thinking about Error Propagation in SSTS and GLib.
 
150
 
 
151
I noticed that errors in GLib does not rely propagate, you can do 
 
152
g_error_propagate () but that assumes that the error that is fed to the function
 
153
is an array. This assumption can never be made and makes it very complex to deal
 
154
with different ways of doing things in different parts of a program (GError * vs
 
155
GError **).
 
156
 
 
157
So what I am thinking of doing is a little more complex: have explicit 
 
158
registration of error domains (s_error_domain_register (schar * name,
 
159
FuncPointer to_string), s_error_domain_is_registered (schar *)).
 
160
 
 
161
The other thing I was thinking is that errors should have implicit propagation.
 
162
(IE: no s_error_new () only s_error_append ()) and have the propagation
 
163
information stored in an array. (ID and message).
 
164
 
 
165
The problem with this is that where do you call s_error_domain_register ()?
 
166
 
 
167
In the constructor of an SObject would be a great place to put it, if not for
 
168
the problem that we have to call s_error_domain_is_registered when a new
 
169
instance of an object is created.
 
170
 
 
171
In the main function is just tedious, Wrapping the main function in something
 
172
like an S_MAIN macro could work and have an internal
 
173
s_library_register_error_domains function somewhere and require the user to
 
174
implement an s_user_register_error_domains function.
 
175
 
 
176
This puts even more work on the shoulders of the developers that uses the
 
177
library.
 
178
 
 
179
It seems that no matter what I do (A true propagating error system or
 
180
something like GError from GLib) I put extra work in the lap of the developer
 
181
that uses the library.
 
182
 
 
183
Commets?
 
184
 
 
185
##########
 
186
 
 
187
void
 
188
s_error_domain_register (schar * domain, SErrorDomainToString func);
 
189
 
 
190
sboolean
 
191
s_error_domain_is_registerd (schar * domain);
 
192
#endif
 
193
 
142
194
/** @} */
143
195
 
144
196
END_DECLS