Solved

Mac Programming question

Posted on 1997-06-20
3
198 Views
Last Modified: 2013-12-26
I saw a code sample some time ago that I believe used a STR# resource built into the system to translate sn OSErr error code into an english message. Does anyonw know the resource ID or of any other built-in way to do this. I want to avoid creating a masssive case statement that I have to maintain.
0
Comment
Question by:creality
3 Comments
 
LVL 1

Accepted Solution

by:
Paul B earned 0 total points
ID: 1291517
Yes you can get the error text built in :)
It is tricky though.

There is a file in your development environment called SysErrs.err.
For Codewarior it is in Metrowerks:Metrowerks Codewarior:SysErrs.err.

COPY this file to the same folder as your application.
I am not sure if it works with aliases.

In your project file you need to link with either PPCToolLibs.o for PPC or NuToolLibs.o for 68K

In your source code:
#include <string.h>
#include <stdio.h>

#include <ErrMgr.h>               // Error manager include
#include <Errors.h>

void main(void)
{
    char errorstring[256];        // buffer for error text
    OSErr err;                    // error number
 
    printf("Error test\n");
    pascalStrings = true;         // pascal string for errors
                                  // init the error manager
                                  // first param is path to tool error file
                                  // second is pacth to sys error file
                                  // since the file is in the same folder
                                  // we pass null
                                  // last param to incluyde error number in text
    InitErrMgr(NULL, NULL, true);


      err = notEnoughHardwareErr;   // some error number
                                    // get the error text
      GetSysErrText(err, errorstring);
                                  
      p2cstr((StringPtr)errorstring);// convert pascal to C string
                                     // display error
      printf("%d %s\n", err, errorstring);

}

You may want to look at <ErrMgr.h> for more detail
Good Luck
Paul Baxter
pbaxter@assistivetech.com
0
 

Author Comment

by:creality
ID: 1291518
Paul answer was great. He even provided some source code as a sample, going beyond what I would have expected.



Thanks Paul.
0
 
LVL 3

Expert Comment

by:rickyr
ID: 1291519
Hi.
It is good to see that some are here to help others, rather than for the points.
a perfect example to set for other forums.

All credit to you creality.


0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 130
EvenOdd challenge 10 108
Making an alias 7 95
Excel file not created as expected 7 72
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question