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


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: 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 | # ]