]> git.imager.perl.org - imager.git/blobdiff - error.c
the PERL_INITIALIZE_IMAGER_PERL_CALLBACKS was checking the wrong version number
[imager.git] / error.c
diff --git a/error.c b/error.c
index 3dcab3cd1a9f5e0a1f544ecc1eb011881860e475..755f69d1e73d21833eca63821fafa5b8ff412027 100644 (file)
--- a/error.c
+++ b/error.c
@@ -183,12 +183,12 @@ the mark.
 =over
 
 =item i_clear_error()
-
+=synopsis i_clear_error();
 =category Error handling
 
 Clears the error stack.
 
-Called by any imager function before doing any other processing.
+Called by any Imager function before doing any other processing.
 
 =cut
 */
@@ -209,10 +209,11 @@ void i_clear_error() {
 
 /*
 =item i_push_error(int code, char const *msg)
-
+=synopsis i_push_error(0, "Yep, it's broken");
+=synopsis i_push_error(errno, "Error writing");
 =category Error handling
 
-Called by an imager function to push an error message onto the stack.
+Called by an Imager function to push an error message onto the stack.
 
 No message is pushed if the stack is full (since this means someone
 forgot to call i_clear_error(), or that a function that doesn't do
@@ -246,13 +247,15 @@ void i_push_error(int code, char const *msg) {
 }
 
 /*
-=item i_push_errorvf(int code, char const *fmt, va_list ap)
+=item i_push_errorvf(int C<code>, char const *C<fmt>, va_list C<ap>)
 
 =category Error handling
 
 Intended for use by higher level functions, takes a varargs pointer
 and a format to produce the finally pushed error message.
 
+Does not support perl specific format codes.
+
 =cut
 */
 void i_push_errorvf(int code, char const *fmt, va_list ap) {
@@ -271,10 +274,12 @@ void i_push_errorvf(int code, char const *fmt, va_list ap) {
 
 /*
 =item i_push_errorf(int code, char const *fmt, ...)
-
+=synopsis i_push_errorf(errno, "Cannot open file %s: %d", filename, errno);
 =category Error handling
 
-A version of i_push_error() that does printf() like formating.
+A version of i_push_error() that does printf() like formatting.
+
+Does not support perl specific format codes.
 
 =cut
 */
@@ -321,7 +326,7 @@ int i_failed(int code, char const *msg) {
       ++sp;
     }
     /* we want to log the error too, build an error message to hand to
-       m_fatal() */
+       i_fatal() */
     total = 1; /* remember the NUL */
     for (sp = error_sp; error_stack[sp].msg; ++sp) {
       total += strlen(error_stack[sp].msg) + 2;
@@ -338,7 +343,7 @@ int i_failed(int code, char const *msg) {
     }
     /* lose the extra ": " */
     full[strlen(full)-2] = '\0';
-    m_fatal(EXIT_FAILURE, "%s", full);
+    i_fatal(EXIT_FAILURE, "%s", full);
   }
 
   return 0;
@@ -346,6 +351,21 @@ int i_failed(int code, char const *msg) {
 
 #endif
 
+/*
+=item im_assert_fail(file, line, message)
+
+Called when an im_assert() assertion fails.
+
+=cut
+*/
+
+void
+im_assert_fail(char const *file, int line, char const *message) {
+  fprintf(stderr, "Assertion failed line %d file %s: %s\n", 
+         line, file, message);
+  exit(EXIT_FAILURE);
+}
+
 /*
 =back