summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:03:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:03:51 +0000
commitff9d9088329fc8270d1d9b89faf9187c33a854ac (patch)
tree83ba84ac1123313569f6a9613aef7bb8e0757585 /error.c
parentf6fbdf261e30763a6eb23ede963d555f16806b15 (diff)
* include/ruby/ruby.h (rb_bug_errno): declared.
* include/ruby/intern.h (rb_strerrno): declaration removed. * error.c (rb_strerrno): make it static. return NULL for unknown errors. (rb_bug_errno): defined. * thread_pthread.c: use rb_bug_errno. * signal.c (ruby_signal): use rb_bug_errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/error.c b/error.c
index 9633e9e252..55834a3cd8 100644
--- a/error.c
+++ b/error.c
@@ -24,6 +24,17 @@
extern const char ruby_description[];
+static const char *
+rb_strerrno(int err)
+{
+#define defined_error(name, num) if (err == num) return name;
+#define undefined_error(name)
+#include "known_errors.inc"
+#undef defined_error
+#undef undefined_error
+ return NULL;
+}
+
static int
err_position_0(char *buf, long len, const char *file, int line)
{
@@ -236,6 +247,20 @@ rb_bug(const char *fmt, ...)
}
void
+rb_bug_errno(const char *mesg, int errno_arg)
+{
+ if (errno_arg == 0)
+ rb_bug("%s: errno == 0 (NOERROR)", mesg);
+ else {
+ const char *errno_str = rb_strerrno(errno_arg);
+ if (errno_str)
+ rb_bug("%s: %s (%s)", mesg, strerror(errno_arg), errno_str);
+ else
+ rb_bug("%s: %s (%d)", mesg, strerror(errno_arg), errno_arg);
+ }
+}
+
+void
rb_compile_bug(const char *file, int line, const char *fmt, ...)
{
va_list args;
@@ -1258,18 +1283,6 @@ Init_syserr(void)
#undef undefined_error
}
-const char *
-rb_strerrno(int err)
-{
- if (err == 0) return "NOERROR";
-#define defined_error(name, num) if (err == num) return name;
-#define undefined_error(name)
-#include "known_errors.inc"
-#undef defined_error
-#undef undefined_error
- return "UNKNOWNERROR";
-}
-
static void
err_append(const char *s)
{