Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Search a list of standard Mac error codes for more info UNIX
There is a list of Mac error codes in the Carbon CoreServices framework header file. To search it, you can just use grep, or the following shell script:
#!/bin/sh

# NOTE: Enter the following two lines as one line
#       without ANY additional spaces:
/usr/bin/grep "$1" /System/Library/Frameworks/CoreServices.framework/
Versions/A/Frameworks/CarbonCore.framework/Headers/MacErrors.h
Give it a name, save it and make it executable (chmod script_name 755). Once saved, you can do something like this (assuming a script name of "errcode"):
% % errcode 5402
  qtsBadDataErr      = -5402, /* something is wrong with the data */
This script helped me find out why I was unable to save to disk at one time -- my disk quota was up, and instead of telling me directly, it gave me an error code I had to look up. Hope this helps someone else.
    •    
  • Currently 2.38 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (8 votes cast)
 
[165,138 views]  

Search a list of standard Mac error codes for more info | 16 comments | Create New Account
Click here to return to the 'Search a list of standard Mac error codes for more info' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Search a list of standard Mac error codes for more info
Authored by: displaced on Jun 05, '03 11:18:48AM

Neat. Thanks!

Apple's error handling seems to be great at letting the user know when they've done something wrong, with verbose text and a good explanation of correct usage...

... but when the system trips over itself, the best it can do is burp up a number.

This'll help clear up those cases ....



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: TheMacOS.com on Feb 17, '04 12:49:44PM
I tried this hint for error codes, and its not working for me. I have a friend that cant open a file, error code: -10660 any ideas what this error means? can I download these OSX errors somewhere? perhaps as an app? thanks.

---
-Admin
http://www.TheMacOS.com

[ Reply to This | # ]

Or as alias... With more...
Authored by: cstuder on Jun 05, '03 11:39:36AM
Or you put the this line into your .tcsrc-file:

alias errcode 'grep \!* /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Headers/MacErrors.h | more'

(Again all on one line.)

The appended | more will help you if there are a lot of error messages to skim trough. (Try searching for '16' for example.) Bye, christian

[ Reply to This | # ]

Needs Dev Tools installed
Authored by: zacht on Jun 05, '03 12:20:30PM

You have to have the Developer Tools installed for this to work; otherwise you don't have the Headers directory.

I had installed Developer Tools a while ago and then recently reinstalled my system, so this didn't work at first. I was going to complain but it occured to me to try rerunning the Dev Tools installer, and that fixed it up.



[ Reply to This | # ]
Another path
Authored by: Landru on Jun 05, '03 12:33:20PM
Actually an improved approach would be to follow the "Current" symlink in the path to the header file to insure that you are always using the latest framework.

grep $1 /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/CarbonCore.framework/Headers/MacErrors.h

If Apple decides to revise the framework to version "B", the path as written in the tip would no longer work work.

---
"You will all be of the body soon."

[ Reply to This | # ]

Search a list of standard Mac error codes for more info
Authored by: mcglk on Jun 05, '03 01:40:06PM

This script still has some problems. First of all, you can't easily search for a negative value. This can be fixed with the "--" option, a common option in GNU utilities which means "everything after this that starts with a dash is actually a parameter, not an argument."

Here's an attempt to put a revised script in a form that will fit into this narrow column.

#!/bin/sh

GREP="/usr/bin/grep"

SYSLIBFRAME="/System/Library/Frameworks"
CORESERVFRAME="$SYSLIBFRAME/CoreServices.framework"
CURRENTFRAME="$CORESERVFRAME/Versions/Current/Frameworks"
CARBONHEADERS="$CURRENTFRAME/CarbonCore.framework/Headers"

$GREP -- "$1" $CARBONHEADERS/MacErrors.h

The script still has a problem in that searching for -2 will present -2, -21, -22, -200, and so forth. The way around that is to make sure you put a comma after the number: "-2," will just bring up the error code for -2. A better way would be to make a switch for this shell script that executes a constrained grep or a free grep, but it's so trivial to put a comma after the number that I'm not going to bother; I'll leave it as an exercise to the reader.

Note that I made a variable for the grep executable. This is just a good habit to get into; it makes porting any Bourne shell script to another platform that much easier. Not that this is likely to be relevant on another platform, but it might come in handy somewhere in a slightly mutated form. Recycling is good.

One final note. A lot of people seem to prefer making these aliases rather than shell scripts. I would actually discourage against that; aliases are strongly shell-dependent, whereas a Bourne shell script will run on pretty much any Unix/Linux variant. I use aliases for very brief commands (alias dir='/bin/ls -asFC', for example), but that's pretty much it. Not everyone uses the same shell you do, after all.



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: mcglk on Jun 05, '03 01:42:03PM

This script still has some problems. First of all, you can't easily search for a negative value. This can be fixed with the "--" option, a common option in GNU utilities which means "everything after this that starts with a dash is actually a parameter, not an argument."

Here's an attempt to put a revised script in a form that will fit into this narrow column.

#!/bin/sh

GREP="/usr/bin/grep"

SYSLIBFRAME="/System/Library/Frameworks"
CORESERVFRAME="$SYSLIBFRAME/CoreServices.framework"
CURRENTFRAME="$CORESERVFRAME/Versions/Current/Frameworks"
CARBONHEADERS="$CURRENTFRAME/CarbonCore.framework/Headers"

$GREP -- "$1" $CARBONHEADERS/MacErrors.h

The script still has a problem in that searching for -2 will present -2, -21, -22, -200, and so forth. The way around that is to make sure you put a comma after the number: "-2," will just bring up the error code for -2. A better way would be to make a switch for this shell script that executes a constrained grep or a free grep, but it's so trivial to put a comma after the number that I'm not going to bother; I'll leave it as an exercise to the reader.

Note that I made a variable for the grep executable. This is just a good habit to get into; it makes porting any Bourne shell script to another platform that much easier. Not that this is likely to be relevant on another platform, but it might come in handy somewhere in a slightly mutated form. Recycling is good.

One final note. A lot of people seem to prefer making these aliases rather than shell scripts. I would actually discourage against that; aliases are strongly shell-dependent, whereas a Bourne shell script will run on pretty much any Unix/Linux variant. I use aliases for very brief commands (alias dir='/bin/ls -asFC', for example), but that's pretty much it. Not everyone uses the same shell you do, after all.



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: mcglk on Jun 05, '03 01:47:57PM

How the heck did this wind up being posted twice?



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: osx_4me on Jun 05, '03 01:44:25PM

Well, with the first alias version (cstudor) - meaning, creating an alias in the .tcsrc file, in my case the .tcshrc file,
I get:
0: Event not found
when opening a new session/terminal window. Entering the command manually (with a specific error number) works.

With the second version (Landru), I get:
unmatched .
And I double-checked and triple-checked the entry.

Hmm... can I assume that you're using the default shell ? Or am I an unworthy whelp for not using Bash ?



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: cstuder on Jun 05, '03 05:56:01PM
Yes, it's called .tcshrc, my bad.

And my version does work here (With all the drawbacks listed by the other users. Remember that it needs to be written on one line, including the 's. Copy & Paste might fail... Or your texteditor might put newlines in it...

Good luck,
christian

[ Reply to This | # ]

Search a list of standard Mac error codes for more info
Authored by: AndyF on Jun 05, '03 02:49:10PM

Another alternative:

grep -e "$1" -w ....

The -w tells grep to look for "words", and the -e says the next thing is the pattern to look for.



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: Brontojoris on Jun 05, '03 08:15:24PM
Not sure why but I had to use

\!:1

instead of

"$1"

[ Reply to This | # ]

Search a list of standard Mac error codes for more info
Authored by: discordantus on Jun 05, '03 08:24:19PM
Here a version written in perl; it supports negative error codes, filters out all the un-asked-for codes, and formats the whole thing prettily. It also supports multiple error codes.

useage:
errcode num [num2 ... ]
Code:


#!/usr/bin/perl
use warnings;
use strict;

# variables:
my ($path,$file,$name,$desc,$errnum);

# set the path to the header file
$path = '/System/Library/Frameworks/'
.'CoreServices.framework/Versions/Current/Frameworks/'
.'CarbonCore.framework/Versions/Current/Headers/MacErrors.h';

# open it and search for each argument.
while($errnum=shift){
    open $file, '<', $path;
    while(<$file>){
        if (m/=\s$errnum\,/) {
            $name=$_;
            $name=~s/^\s*(\S*)\s.*$/$1/;
            chomp $name;
            $desc=$_;
            $desc=~s:^.*?/\*(.*)\*/:$1:;
            chomp $desc;
            print "$name ($errnum): $desc", "\n";
        }
    }
    close $file;
}

exit 0;
example:
user1%> errcode -42 23 -69
tmfoErr (-42): too many files open
dsNoPk6 (23): package 6 not present
badCksmErr (-69): addr mark checksum didn't check


[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: maartensneep on Jun 06, '03 07:39:50AM

You may need a little more filtering here, try errorcode -1. I don't know enough perl to do this myself, and besides, the issue is merely cosmetic.

Regards,

Maarten



[ Reply to This | # ]
Search a list of standard Mac error codes for more info
Authored by: discordantus on Jun 09, '03 05:41:30AM
I browsed through the header file, and it seems that there are sometimes more than one definitions for a particular error code -- 42 comes up twice, -1 comes up three times -- and it's impossible for me to tell if only one of these is correct, or all of them. So I'll keep them all in there, unless someone can tell me which ones to keep.

On another note, I also noticed that there are a lot of codes that didn't have commas after the numbers, and a lot that don't have comments after them. the script I posted seems to clear those out. So here is a revised script: it's shorter, works better, and prints even prettier to boot. :)


#!/usr/bin/perl
use warnings; use strict;

# usage: errcode num [num2]

my ($path,$file,$errn,$ferrn);

# set the path to the header file
$path = '/System/Library/Frameworks/'
.'CoreServices.framework/Versions/Current/Frameworks/'
.'CarbonCore.framework/Versions/Current/Headers/MacErrors.h';

# open it and search for each argument.
while($errn=shift){
    $ferrn=" "x(6-length($errn))."($errn): ";
    open $file, '<', $path;
    while(<$file>){
        print $1, $ferrn, $2||"[no description]", "\n"
            if (m!^\s*(\S*\s+)\s=\s$errn[,]?\s+(?:/\*\s?(.*?)\s?\*/\s*)?$!);
    } close $file;
} exit 0;


[ Reply to This | # ]
Non-Terminal error search
Authored by: jvr on Jun 15, '03 12:49:20PM

Here's a non-terminal solution for this task:

Create an alias to the aforementioned file in your Documents folder (or wherever you like). Then just open the alias in a text editor like BBEdit or TextEdit and use the built-in "Find" function. No fancy code here; just open and search.

Thanks for pointing out the existence of this file. I had no idea it was there.



[ Reply to This | # ]