2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 * Copyright 1988-1996, NeXT Software, Inc.
30 NXLogObjcError was snarfed from "logErrorInc.c" in the kit.
32 Contains code for writing error messages to stderr or syslog.
34 This code is included in errors.m in the kit, and in pbs.c
35 so pbs can use it also.
44 #define syslog(a, b, c) fprintf(stderr, b, c)
51 #include <syslog.h> // major head banging in attempt to find syslog
53 #include <unistd.h> // close
55 #import <fcntl.h> // file open flags
58 #import "objc-private.h"
61 * this routine handles errors that involve an object (or class).
63 volatile void __objc_error(id rcv, const char *fmt, ...)
68 (*_error)(rcv, fmt, vp);
70 _objc_error (rcv, fmt, vp); /* In case (*_error)() returns. */
74 * this routine is never called directly...it is only called indirectly
75 * through "_error", which can be overriden by an application. It is
76 * not declared static because it needs to be referenced in
77 * "objc-globaldata.m" (this file organization simplifies the shlib
78 * maintenance problem...oh well). It is, however, a "private extern".
80 volatile void _objc_error(id self, const char *fmt, va_list ap)
82 char bigBuffer[4*1024];
84 vsprintf (bigBuffer, fmt, ap);
85 _NXLogError ("objc: %s: %s", object_getClassName (self), bigBuffer);
88 RaiseException(0xdead, EXCEPTION_NONCONTINUABLE, 0, NULL);
90 abort(); /* generates a core file */
95 * this routine handles severe runtime errors...like not being able
96 * to read the mach headers, allocate space, etc...very uncommon.
98 volatile void _objc_fatal(const char *msg)
100 _NXLogError("objc: %s\n", msg);
102 RaiseException(0xdead, EXCEPTION_NONCONTINUABLE, 0, NULL);
109 * this routine handles soft runtime errors...like not being able
110 * add a category to a class (because it wasn't linked in).
112 void _objc_inform(const char *fmt, ...)
115 char bigBuffer[4*1024];
118 vsprintf (bigBuffer, fmt, ap);
119 _NXLogError ("objc: %s", bigBuffer);