always link against cocoa framework on Mac OS X, cocoa exception wrapping in xpcom file io. b=419392 r=bent sr=roc a=beltzner
authorjoshmoz@gmail.com
Fri, 29 Feb 2008 15:24:53 -0800
changeset 12447 05ad4eb47b65c17beca933dac9255c31c59062a2
parent 12446 b44dd3d3ee5b4e0bf85d309f80ed6c47f8aa5114
child 12448 97815eee4e84b10c64f770a724c39adc95102acc
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, roc, beltzner
bugs419392
milestone1.9b4pre
always link against cocoa framework on Mac OS X, cocoa exception wrapping in xpcom file io. b=419392 r=bent sr=roc a=beltzner
accessible/build/Makefile.in
browser/app/Makefile.in
configure.in
embedding/componentlib/Makefile.in
extensions/spellcheck/src/Makefile.in
gfx/thebes/src/Makefile.in
modules/libpr0n/decoders/icon/Makefile.in
modules/staticmod/Makefile.in
toolkit/components/alerts/src/mac/Makefile.in
toolkit/library/Makefile.in
widget/src/cocoa/Makefile.in
xpcom/io/nsLocalFileOSX.mm
--- a/accessible/build/Makefile.in
+++ b/accessible/build/Makefile.in
@@ -88,18 +88,14 @@ EXTRA_DSO_LDOPTS =           \
 	$(MOZ_UNICHARUTIL_LIBS)  \
 	$(MOZ_COMPONENT_LIBS)    \
 	$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-EXTRA_DSO_LDOPTS += -framework Cocoa
-endif
-
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += oleaut32.lib
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -109,17 +109,17 @@ else
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 LIBS += $(DIST)/bin/XUL
 else
 EXTRA_DSO_LIBS += xul
 endif
 endif
 
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
-TK_LIBS := -framework Cocoa $(TK_LIBS)
+TK_LIBS := $(TK_LIBS)
 endif
 
 ifdef MOZ_ENABLE_LIBXUL
 APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS)
 else
 MOZILLA_INTERNAL_API = 1
 APP_XPCOM_LIBS = $(XPCOM_LIBS)
 endif
@@ -232,17 +232,17 @@ DEFINES += -DMOZILLA_OFFICIAL
 endif
 
 ifdef BUILD_STATIC_LIBS
 include $(topsrcdir)/config/static-rules.mk
 
 DEFINES += -DIMPL_XREAPI
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 ifdef BUILD_STATIC_LIBS
 ifdef USE_PREBINDING
 BIN_FLAGS += -Wl,-headerpad -Wl,5a0c
 endif
 endif
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),photon)
--- a/configure.in
+++ b/configure.in
@@ -1612,16 +1612,17 @@ case "$target" in
     CFLAGS="$CFLAGS -fpascal-strings -fno-common"
     CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
     DLL_SUFFIX=".dylib"
     DSO_LDOPTS=''
     STRIP="$STRIP -x -S"
     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
     MOZ_ENABLE_POSTSCRIPT=
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
+    LDFLAGS="$LDFLAGS -framework Cocoa"
     # set MACOSX to generate lib/mac/MoreFiles/Makefile
     MACOSX=1
 
     dnl check for the presence of the -dead_strip linker flag
     AC_MSG_CHECKING([for -dead_strip option to ld])
     _SAVE_LDFLAGS=$LDFLAGS
     LDFLAGS="$LDFLAGS -Wl,-dead_strip"
     AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
--- a/embedding/componentlib/Makefile.in
+++ b/embedding/componentlib/Makefile.in
@@ -87,24 +87,20 @@ EXTRA_DSO_LDOPTS += \
 	$(EXTRA_DSO_LIBS) \
 	$(STATIC_EXTRA_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(TK_LIBS) \
 	$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 OS_LIBS	+= -framework QuickTime
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-OS_LIBS	+= -framework Cocoa
-endif
-
 ifeq ($(OS_ARCH),Darwin)
 
 # A limitation exists in the Mach-O format which causes "scattered" relocation
 # entries in shared libraries to be limited to a 24-bit address space (16 MB).
 # The high 8 bits of the address are dropped.  This can cause problems in
 # a mozcomps build, particularly non-optimized builds.  To avoid the problem,
 # we move the data segment before the code segment in the libraray.  The data
 # segment is relatively small, and all of the relocations in question
--- a/extensions/spellcheck/src/Makefile.in
+++ b/extensions/spellcheck/src/Makefile.in
@@ -91,15 +91,8 @@ EXTRA_DSO_LDOPTS = \
 		$(MOZ_HUNSPELL_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
 	-I$(topsrcdir)/xpcom/io \
 	$(NULL)
-
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-LDFLAGS	+= \
-	-framework Cocoa \
-	-framework Foundation \
-	$(NULL)
-endif
--- a/gfx/thebes/src/Makefile.in
+++ b/gfx/thebes/src/Makefile.in
@@ -93,33 +93,32 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
 CPPSRCS	+= 	gfxBeOSSurface.cpp gfxBeOSPlatform.cpp
 CPPSRCS +=	gfxPangoFonts.cpp 
 #CPPSRCS +=	gfxPDFSurface.cpp
 CPPSRCS +=	gfxFontconfigUtils.cpp
 CPPSRCS +=	nsUnicodeRange.cpp
 EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(CAIRO_FT_LIBS) -lfontconfig -lpangocairo-1.0
 endif
 
-
-ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CPPSRCS	+= \
 	gfxQuartzSurface.cpp \
 	gfxQuartzImageSurface.cpp \
 	gfxQuartzPDFSurface.cpp \
 	gfxPlatformMac.cpp \
 	gfxAtsuiFonts.cpp \
 	$(NULL)
 #CPPSRCS +=	gfxPDFSurface.cpp
 CPPSRCS +=      nsUnicodeRange.cpp
 CPPSRCS +=      gfxQuartzNativeDrawing.cpp
 
 CMMSRCS = gfxQuartzFontCache.mm
 
 # Always link with OpenGL/AGL
-EXTRA_DSO_LDOPTS += -framework OpenGL -framework AGL -framework Cocoa -framework QuickTime
+EXTRA_DSO_LDOPTS += -framework OpenGL -framework AGL -framework QuickTime
 endif
 
 ifdef MOZ_ENABLE_GLITZ
 REQUIRES += 	glitz
 CPPSRCS +=	gfxGlitzSurface.cpp
 
 SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mozglitz.$(LIB_SUFFIX)
 
@@ -129,17 +128,17 @@ SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB
 OS_LIBS += opengl32.lib 
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 REQUIRES +=	glitzglx
 SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mozglitzglx.$(LIB_SUFFIX)
 endif
 
-ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 REQUIRES +=	glitzagl
 SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mozglitzagl.$(LIB_SUFFIX)
 endif
 endif
 
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 
 DEFINES += -DIMPL_THEBES
--- a/modules/libpr0n/decoders/icon/Makefile.in
+++ b/modules/libpr0n/decoders/icon/Makefile.in
@@ -118,17 +118,13 @@ EXTRA_DSO_LDOPTS += \
 endif
 
 LOCAL_INCLUDES	= -I$(srcdir)/$(PLATFORM)
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS		+= $(call EXPAND_LIBNAME,shell32 gdi32 comctl32)
 endif
 
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-OS_LIBS += -framework Cocoa
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),Darwin)
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
--- a/modules/staticmod/Makefile.in
+++ b/modules/staticmod/Makefile.in
@@ -67,24 +67,20 @@ EXTRA_DSO_LDOPTS = \
 		$(XPCOM_GLUE_LDOPTS) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 OS_LIBS	+= -framework QuickTime
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-OS_LIBS	+= -framework Cocoa
-endif
-
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool imm32)
 # XXX temporary workaround until link ordering issue is solved
 ifdef GNU_CC
 OS_LIBS += $(call EXPAND_LIBNAME,winmm wsock32 gdi32)
 endif
 OS_LIBS += $(call EXPAND_LIBNAME, usp10)
 endif
--- a/toolkit/components/alerts/src/mac/Makefile.in
+++ b/toolkit/components/alerts/src/mac/Makefile.in
@@ -74,14 +74,13 @@ EXPORTS = \
   $(NULL)
 
 SHARED_LIBRARY_LIBS = \
   growl/$(LIB_PREFIX)growl_s.$(LIB_SUFFIX) \
   $(NULL)
 
 EXTRA_DSO_LDOPTS += \
   -framework Carbon \
-  -framework Cocoa \
   $(XPCOM_GLUE_LDOPTS) \
   $(NSPR_LIBS) \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -48,17 +48,17 @@ endif
 include $(topsrcdir)/intl/unicharutil/util/objs.mk
 
 MODULE = libxul
 LIBRARY_NAME = xul
 FORCE_USE_PIC = 1
 FORCE_SHARED_LIB = 1
 MOZILLA_INTERNAL_API = 1
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 # This is going to be a framework named "XUL", not an ordinary library named
 # "libxul.dylib"
 LIBRARY_NAME=XUL
 # Setting MAKE_FRAMEWORK makes DLL_PREFIX and DLL_SUFFIX be ignored when
 # setting SHARED_LIBRARY; we need to leave DLL_PREFIX and DLL_SUFFIX
 # as-is so that dependencies of the form -ltracemalloc still work.
 MAKE_FRAMEWORK=1
 endif
@@ -103,17 +103,17 @@ LOCAL_INCLUDES += \
 ifeq ($(OS_ARCH),WINNT)
 CPPSRCS += dlldeps-javaxpcom.cpp
 LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/win32
 else
 ifeq ($(OS_ARCH),OS2)
 CPPSRCS += dlldeps-javaxpcom.cpp
 LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/os2
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 EXTRA_DSO_LDOPTS += -framework JavaVM
 else
 LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/linux
 endif
 endif
 endif
 
 SHARED_LIBRARY_LIBS += \
@@ -194,20 +194,19 @@ EXTRA_DSO_LDOPTS += \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 endif
 
 DEFINES += -DIMPL_XREAPI
 
 EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CXXFLAGS	+= $(TK_CFLAGS)
 EXTRA_DSO_LDOPTS += \
-	-framework Cocoa \
 	-framework QuickTime \
 	-framework IOKit \
 	-lcrypto \
 	$(TK_LIBS) \
 	$(NULL)
 endif
 
 ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT))
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -172,11 +172,9 @@ libs:: $(RESOURCE)
 LOCAL_INCLUDES	= \
 	$(TK_CFLAGS) \
 	-I$(srcdir)/../xpwidgets \
 	$(NULL)
 
 LDFLAGS	+= \
 	-framework QuickTime \
 	-framework IOKit \
-	-framework Cocoa \
-	-framework Foundation \
 	$(NULL)
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -37,16 +37,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsLocalFile.h"
 #include "nsDirectoryServiceDefs.h"
 
+#include "nsObjCExceptions.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsISimpleEnumerator.h"
 #include "nsITimelineService.h"
 #include "nsVoidArray.h"
 
 #include "plbase64.h"
@@ -56,16 +57,17 @@
 
 #include "MoreFilesX.h"
 #include "FSCopyObject.h"
 #include "nsTArray.h"
 #include "nsTraceRefcntImpl.h"
 
 // Mac Includes
 #include <Carbon/Carbon.h>
+#import <Cocoa/Cocoa.h>
 
 // Unix Includes
 #include <unistd.h>
 #include <sys/stat.h>
 #include <stdlib.h>
 
 #if !defined(MAC_OS_X_VERSION_10_4) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
 #define GetAliasSizeFromRecord(aliasRecord) aliasRecord.aliasSize
@@ -91,17 +93,21 @@ static void CopyUTF8toUTF16NFC(const nsA
 //  Local Helper Classes
 //*****************************************************************************
 
 #pragma mark -
 #pragma mark [FSRef operator==]
 
 bool operator==(const FSRef& lhs, const FSRef& rhs)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
   return (::FSCompareFSRefs(&lhs, &rhs) == noErr);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
 #pragma mark -
 #pragma mark [StFollowLinksState]
 
 class StFollowLinksState
 {
   public:
@@ -142,16 +148,18 @@ class nsDirEnumerator : public nsISimple
           mIterator(nsnull),
           mFSRefsArray(nsnull),
           mArrayCnt(0), mArrayIndex(0)
         {
         }
 
         nsresult Init(nsILocalFileMac* parent) 
         {
+          NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
           NS_ENSURE_ARG(parent);
           
           OSErr err;
           nsresult rv;
           FSRef parentRef;
           
           rv = parent->GetFSRef(&parentRef);
           if (NS_FAILED(rv))
@@ -162,20 +170,24 @@ class nsDirEnumerator : public nsISimple
           if (!mFSRefsArray)
             return NS_ERROR_OUT_OF_MEMORY;
           
           err = ::FSOpenIterator(&parentRef, kFSIterateFlat, &mIterator);
           if (err != noErr)
             return MacErrorMapper(err);
                               
           return NS_OK;
+
+          NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
         }
 
         NS_IMETHOD HasMoreElements(PRBool *result) 
         {
+          NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
           if (mNext == nsnull) {
             if (mArrayIndex >= mArrayCnt) {
               ItemCount actualCnt;
               OSErr err = ::FSGetCatalogInfoBulk(mIterator,
                                            kRequestCountPerIteration,
                                            &actualCnt,
                                            nsnull,
                                            kFSCatInfoNone,
@@ -199,16 +211,18 @@ class nsDirEnumerator : public nsISimple
               mArrayIndex++;
               mNext = newFile;
             } 
           }
           *result = mNext != nsnull;
           if (!*result)
             Close();
           return NS_OK;
+
+          NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
         }
 
         NS_IMETHOD GetNext(nsISupports **result) 
         {
             NS_ENSURE_ARG_POINTER(result);
             *result = nsnull;
 
             nsresult rv;
@@ -233,25 +247,29 @@ class nsDirEnumerator : public nsISimple
             *result = mNext;
             NS_IF_ADDREF(*result);
             mNext = nsnull;
             return NS_OK;
         }
 
         NS_IMETHOD Close()
         {
+          NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
           if (mIterator) {
             ::FSCloseIterator(mIterator);
             mIterator = nsnull;
           }
           if (mFSRefsArray) {
             nsMemory::Free(mFSRefsArray);
             mFSRefsArray = nsnull;
           }
           return NS_OK;
+
+          NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
         }
 
     private:
         ~nsDirEnumerator() 
         {
           Close();
         }
 
@@ -280,17 +298,21 @@ public:
     StAEDesc()
     {
       descriptorType = typeNull;
       dataHandle = nil;
     }
               
     ~StAEDesc()
     {
+      NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
       ::AEDisposeDesc(this);
+
+      NS_OBJC_END_TRY_ABORT_BLOCK;
     }
 };
 
 #define FILENAME_BUFFER_SIZE 512
 
 //*****************************************************************************
 //  nsLocalFile
 //*****************************************************************************
@@ -318,45 +340,53 @@ nsLocalFile::nsLocalFile() :
 nsLocalFile::nsLocalFile(const nsLocalFile& src) :
   mBaseRef(src.mBaseRef),
   mTargetRef(src.mTargetRef),
   mCachedFSRef(src.mCachedFSRef),
   mCachedFSRefValid(src.mCachedFSRefValid),
   mFollowLinks(src.mFollowLinks),
   mFollowLinksDirty(src.mFollowLinksDirty)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
   // A CFURLRef is immutable so no need to copy, just retain.
   if (mBaseRef)
     ::CFRetain(mBaseRef);
   if (mTargetRef)
     ::CFRetain(mTargetRef);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 nsLocalFile::~nsLocalFile()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
   if (mBaseRef)
     ::CFRelease(mBaseRef);
   if (mTargetRef)
     ::CFRelease(mTargetRef);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 //*****************************************************************************
 //  nsLocalFile::nsISupports
 //*****************************************************************************
 #pragma mark -
 #pragma mark [nsISupports]
 
 NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
                               nsILocalFileMac,
                               nsILocalFile,
                               nsIFile,
                               nsIHashable)
                               
-NS_METHOD nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
+NS_IMETHODIMP nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
 {
   NS_ENSURE_ARG_POINTER(aInstancePtr);
   NS_ENSURE_NO_AGGREGATION(outer);
 
   nsLocalFile* inst = new nsLocalFile();
   if (inst == NULL)
     return NS_ERROR_OUT_OF_MEMORY;
   
@@ -380,16 +410,18 @@ NS_METHOD nsLocalFile::nsLocalFileConstr
 NS_IMETHODIMP nsLocalFile::Append(const nsAString& aNode)
 {
   return AppendNative(NS_ConvertUTF16toUTF8(aNode));
 }
 
 /* [noscript] void appendNative (in ACString node); */
 NS_IMETHODIMP nsLocalFile::AppendNative(const nsACString& aNode)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   nsACString::const_iterator start, end;
   aNode.BeginReading(start);
   aNode.EndReading(end);
   if (FindCharInReadable(kPathSepChar, start, end))
     return NS_ERROR_FILE_UNRECOGNIZED_PATH;
@@ -403,21 +435,25 @@ NS_IMETHODIMP nsLocalFile::AppendNative(
     ::CFRelease(nodeStrRef);
     if (newRef) {
       SetBaseRef(newRef);
       ::CFRelease(newRef);
       return NS_OK;
     }
   }
   return NS_ERROR_FAILURE;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void normalize (); */
 NS_IMETHODIMP nsLocalFile::Normalize()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   // CFURL doesn't doesn't seem to resolve paths containing relative
   // components, so we'll nick the stdlib code from nsLocalFileUnix
   UInt8 path[PATH_MAX] = "";
   Boolean success;
   success = ::CFURLGetFileSystemRepresentation(mBaseRef, true, path, PATH_MAX);
@@ -450,21 +486,25 @@ NS_IMETHODIMP nsLocalFile::Normalize()
       SetBaseRef(newURLRef);
       ::CFRelease(newURLRef);
       rv = NS_OK;
     }
     ::CFRelease(pathStrRef);
   }
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void create (in unsigned long type, in unsigned long permissions); */
 NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   if (type != NORMAL_FILE_TYPE && type != DIRECTORY_TYPE)
     return NS_ERROR_FILE_UNKNOWN_TYPE;
 
   // Check we are correctly initialized.
   CHECK_mBaseRef();
   
   nsStringArray nonExtantNodes;
   CFURLRef pathURLRef = mBaseRef;
@@ -531,51 +571,63 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint
     err = ::FSCreateDirectoryUnicode(&pathFSRef,
                                     nextNodeName.Length(),
                                     (const UniChar *)nextNodeName.get(),
                                     kFSCatInfoNone,
                                     nsnull, nsnull, nsnull, nsnull);
   }
             
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute AString leafName; */
 NS_IMETHODIMP nsLocalFile::GetLeafName(nsAString& aLeafName)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsCAutoString nativeString;
   nsresult rv = GetNativeLeafName(nativeString);
   if (NS_FAILED(rv))
     return rv;
   CopyUTF8toUTF16NFC(nativeString, aLeafName);
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetLeafName(const nsAString& aLeafName)
 {
   return SetNativeLeafName(NS_ConvertUTF16toUTF8(aLeafName));
 }
 
 /* [noscript] attribute ACString nativeLeafName; */
 NS_IMETHODIMP nsLocalFile::GetNativeLeafName(nsACString& aNativeLeafName)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   nsresult rv = NS_ERROR_FAILURE;
   CFStringRef leafStrRef = ::CFURLCopyLastPathComponent(mBaseRef);
   if (leafStrRef) {
     rv = CFStringReftoUTF8(leafStrRef, aNativeLeafName);
     ::CFRelease(leafStrRef);
   }
-  return rv;                                  
+  return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetNativeLeafName(const nsACString& aNativeLeafName)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   nsresult rv = NS_ERROR_FAILURE;
   CFURLRef parentURLRef = ::CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, mBaseRef);
   if (parentURLRef) {
     CFStringRef nodeStrRef = ::CFStringCreateWithCString(kCFAllocatorDefault,
                                     PromiseFlatCString(aNativeLeafName).get(),
@@ -589,16 +641,18 @@ NS_IMETHODIMP nsLocalFile::SetNativeLeaf
         ::CFRelease(newURLRef);
         rv = NS_OK;
       }
       ::CFRelease(nodeStrRef);
     }
     ::CFRelease(parentURLRef);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void copyTo (in nsIFile newParentDir, in AString newName); */
 NS_IMETHODIMP nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString& newName)
 {
   return CopyInternal(newParentDir, newName, PR_FALSE);
 }
 
@@ -624,16 +678,18 @@ NS_IMETHODIMP nsLocalFile::CopyToFollowi
 NS_IMETHODIMP nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString& newName)
 {
   return MoveToNative(newParentDir, NS_ConvertUTF16toUTF8(newName));
 }
 
 /* [noscript] void moveToNative (in nsIFile newParentDir, in ACString newName); */
 NS_IMETHODIMP nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString& newName)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   StFollowLinksState followLinks(*this, PR_FALSE);
 
   PRBool isDirectory;
   nsresult rv = IsDirectory(&isDirectory);
   if (NS_FAILED(rv))
@@ -703,21 +759,25 @@ NS_IMETHODIMP nsLocalFile::MoveToNative(
    ::CFURLCreateFromFileSystemRepresentation(NULL, (UInt8*)destPath.get(),
                                              destPath.Length(), isDirectory);
   if (!newBaseRef)
     return NS_ERROR_FAILURE;
   SetBaseRef(newBaseRef);
   ::CFRelease(newBaseRef);
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void remove (in boolean recursive); */
 NS_IMETHODIMP nsLocalFile::Remove(PRBool recursive)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   // XXX If we're an alias, never remove target
   StFollowLinksState followLinks(*this, PR_FALSE);
 
   PRBool isDirectory;
   nsresult rv = IsDirectory(&isDirectory);
@@ -748,54 +808,64 @@ NS_IMETHODIMP nsLocalFile::Remove(PRBool
       status = unlink(pathPtr);
 
     if (status != 0)
       rv = NSRESULT_FOR_ERRNO();
   }
 
   mCachedFSRefValid = PR_FALSE;
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute unsigned long permissions; */
 NS_IMETHODIMP nsLocalFile::GetPermissions(PRUint32 *aPermissions)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aPermissions);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
     
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
                   nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
   *aPermissions = permPtr->mode;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetPermissions(PRUint32 aPermissions)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
                   nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
   permPtr->mode = (UInt16)aPermissions;
   err = ::FSSetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo);
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute unsigned long permissionsOfLink; */
 NS_IMETHODIMP nsLocalFile::GetPermissionsOfLink(PRUint32 *aPermissionsOfLink)
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -804,16 +874,18 @@ NS_IMETHODIMP nsLocalFile::SetPermission
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 /* attribute PRInt64 lastModifiedTime; */
 NS_IMETHODIMP nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   NS_ENSURE_ARG_POINTER(aLastModifiedTime);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
@@ -821,20 +893,24 @@ NS_IMETHODIMP nsLocalFile::GetLastModifi
     
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoContentMod, &catalogInfo,
                                 nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   *aLastModifiedTime = HFSPlustoNSPRTime(catalogInfo.contentModDate);  
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetLastModifiedTime(PRInt64 aLastModifiedTime)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   OSErr err;
   nsresult rv;
   FSRef fsRef;
   FSCatalogInfo catalogInfo;
 
@@ -860,16 +936,18 @@ NS_IMETHODIMP nsLocalFile::SetLastModifi
     return MacErrorMapper(err);
 
   /* Send a notification for the parent of the file, or for the directory */
   err = FNNotify(notifyParent ? &parentRef : &fsRef, kFNDirectoryModifiedMessage, kNilOptions);
   if (err != noErr)
     return MacErrorMapper(err);
 
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute PRInt64 lastModifiedTimeOfLink; */
 NS_IMETHODIMP nsLocalFile::GetLastModifiedTimeOfLink(PRInt64 *aLastModifiedTimeOfLink)
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -877,16 +955,18 @@ NS_IMETHODIMP nsLocalFile::SetLastModifi
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 /* attribute PRInt64 fileSize; */
 NS_IMETHODIMP nsLocalFile::GetFileSize(PRInt64 *aFileSize)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aFileSize);
   *aFileSize = 0;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
       
@@ -896,36 +976,42 @@ NS_IMETHODIMP nsLocalFile::GetFileSize(P
   if (err != noErr)
     return MacErrorMapper(err);
   
   // FSGetCatalogInfo can return a bogus size for directories sometimes, so only
   // rely on the answer for files
   if ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0)
       *aFileSize = catalogInfo.dataLogicalSize;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetFileSize(PRInt64 aFileSize)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
   SInt16 refNum;    
   OSErr err = ::FSOpenFork(&fsRef, 0, nsnull, fsWrPerm, &refNum);
   if (err != noErr)
     return MacErrorMapper(err);
   err = ::FSSetForkSize(refNum, fsFromStart, aFileSize);
   ::FSCloseFork(refNum);  
   
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* readonly attribute PRInt64 fileSizeOfLink; */
 NS_IMETHODIMP nsLocalFile::GetFileSizeOfLink(PRInt64 *aFileSizeOfLink)
 {
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
@@ -944,51 +1030,59 @@ NS_IMETHODIMP nsLocalFile::GetTarget(nsA
     return rv;
   CopyUTF8toUTF16NFC(nativeString, aTarget);
   return NS_OK;
 }
 
 /* [noscript] readonly attribute ACString nativeTarget; */
 NS_IMETHODIMP nsLocalFile::GetNativeTarget(nsACString& aNativeTarget)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   if (!mTargetRef)
     return NS_ERROR_NOT_INITIALIZED;
   nsresult rv = NS_ERROR_FAILURE;
   CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(mTargetRef, kCFURLPOSIXPathStyle);
   if (pathStrRef) {
     rv = CFStringReftoUTF8(pathStrRef, aNativeTarget);
     ::CFRelease(pathStrRef);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* readonly attribute AString path; */
 NS_IMETHODIMP nsLocalFile::GetPath(nsAString& aPath)
 {
   nsCAutoString nativeString;
   nsresult rv = GetNativePath(nativeString);
   if (NS_FAILED(rv))
     return rv;
   CopyUTF8toUTF16NFC(nativeString, aPath);
   return NS_OK;
 }
 
 /* [noscript] readonly attribute ACString nativePath; */
 NS_IMETHODIMP nsLocalFile::GetNativePath(nsACString& aNativePath)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   nsresult rv = NS_ERROR_FAILURE;
   CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(mBaseRef, kCFURLPOSIXPathStyle);
   if (pathStrRef) {
     rv = CFStringReftoUTF8(pathStrRef, aNativePath);
     ::CFRelease(pathStrRef);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean exists (); */
 NS_IMETHODIMP nsLocalFile::Exists(PRBool *_retval)
 {
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
@@ -1001,16 +1095,18 @@ NS_IMETHODIMP nsLocalFile::Exists(PRBool
   }
   
   return NS_OK;
 }
 
 /* boolean isWritable (); */
 NS_IMETHODIMP nsLocalFile::IsWritable(PRBool *_retval)
 {
+    NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
     // Check we are correctly initialized.
     CHECK_mBaseRef();
 
     NS_ENSURE_ARG_POINTER(_retval);
     *_retval = PR_FALSE;
     
     FSRef fsRef;
     nsresult rv = GetFSRefInternal(fsRef);
@@ -1019,16 +1115,18 @@ NS_IMETHODIMP nsLocalFile::IsWritable(PR
     if (::FSCheckLock(&fsRef) == noErr) {      
       PRUint32 permissions;
       rv = GetPermissions(&permissions);
       if (NS_FAILED(rv))
         return rv;
       *_retval = ((permissions & S_IWUSR) != 0);
     }
     return NS_OK;
+
+    NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isReadable (); */
 NS_IMETHODIMP nsLocalFile::IsReadable(PRBool *_retval)
 {
     // Check we are correctly initialized.
     CHECK_mBaseRef();
 
@@ -1041,16 +1139,18 @@ NS_IMETHODIMP nsLocalFile::IsReadable(PR
       return rv;
     *_retval = ((permissions & S_IRUSR) != 0);
     return NS_OK;
 }
 
 /* boolean isExecutable (); */
 NS_IMETHODIMP nsLocalFile::IsExecutable(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
@@ -1059,21 +1159,25 @@ NS_IMETHODIMP nsLocalFile::IsExecutable(
     
   LSRequestedInfo theInfoRequest = kLSRequestAllInfo;
   LSItemInfoRecord theInfo;
   if (::LSCopyItemInfoForRef(&fsRef, theInfoRequest, &theInfo) == noErr) {
     if ((theInfo.flags & kLSItemInfoIsApplication) != 0)
     *_retval = PR_TRUE;
   }
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isHidden (); */
 NS_IMETHODIMP nsLocalFile::IsHidden(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
@@ -1089,77 +1193,91 @@ NS_IMETHODIMP nsLocalFile::IsHidden(PRBo
     *_retval = PR_TRUE;
   }
   else {
     // If the leaf name begins with a '.', consider it invisible
     if (leafName.length >= 1 && leafName.unicode[0] == UniChar('.'))
       *_retval = PR_TRUE;
   }
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isDirectory (); */
 NS_IMETHODIMP nsLocalFile::IsDirectory(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef, PR_FALSE);
   if (NS_FAILED(rv))
     return rv;
     
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNodeFlags, &catalogInfo,
                                 nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   *_retval = ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0);
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isFile (); */
 NS_IMETHODIMP nsLocalFile::IsFile(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef, PR_FALSE);
   if (NS_FAILED(rv))
     return rv;
     
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNodeFlags, &catalogInfo,
                                 nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   *_retval = ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0);
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isSymlink (); */
 NS_IMETHODIMP nsLocalFile::IsSymlink(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   NS_ENSURE_ARG(_retval);
   *_retval = PR_FALSE;
 
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   FSRef fsRef;
   if (::CFURLGetFSRef(mBaseRef, &fsRef)) {
     Boolean isAlias, isFolder;
     if (::FSIsAliasFile(&fsRef, &isAlias, &isFolder) == noErr)
         *_retval = isAlias;
   }
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isSpecial (); */
 NS_IMETHODIMP nsLocalFile::IsSpecial(PRBool *_retval)
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1247,16 +1365,18 @@ NS_IMETHODIMP nsLocalFile::Contains(nsIF
       *_retval = PR_TRUE;
   }  
   return NS_OK;
 }
 
 /* readonly attribute nsIFile parent; */
 NS_IMETHODIMP nsLocalFile::GetParent(nsIFile * *aParent)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aParent);
   *aParent = nsnull;
 
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   nsLocalFile *newFile = nsnull;
 
@@ -1281,16 +1401,18 @@ NS_IMETHODIMP nsLocalFile::GetParent(nsI
           NS_ADDREF(*aParent = newFile);
           rv = NS_OK;
         }
       }
     }
     ::CFRelease(parentURLRef);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* readonly attribute nsISimpleEnumerator directoryEntries; */
 NS_IMETHODIMP nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator **aDirectoryEntries)
 {
   NS_ENSURE_ARG_POINTER(aDirectoryEntries);
   *aDirectoryEntries = nsnull;
 
@@ -1327,16 +1449,18 @@ NS_IMETHODIMP nsLocalFile::GetDirectoryE
 NS_IMETHODIMP nsLocalFile::InitWithPath(const nsAString& filePath)
 {
   return InitWithNativePath(NS_ConvertUTF16toUTF8(filePath));
 }
 
 /* [noscript] void initWithNativePath (in ACString filePath); */
 NS_IMETHODIMP nsLocalFile::InitWithNativePath(const nsACString& filePath)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsCAutoString fixedPath;
   if (Substring(filePath, 0, 2).EqualsLiteral("~/")) {
     nsCOMPtr<nsIFile> homeDir;
     nsCAutoString homePath;
     nsresult rv = NS_GetSpecialDirectory(NS_OS_HOME_DIR,
                                         getter_AddRefs(homeDir));
     NS_ENSURE_SUCCESS(rv, rv);
     rv = homeDir->GetNativePath(homePath);
@@ -1369,33 +1493,39 @@ NS_IMETHODIMP nsLocalFile::InitWithNativ
   if (!pathAsCFURL) {
     ::CFRelease(pathAsCFString);
     return NS_ERROR_FAILURE;
   }
   SetBaseRef(pathAsCFURL);
   ::CFRelease(pathAsCFURL);
   ::CFRelease(pathAsCFString);
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void initWithFile (in nsILocalFile aFile); */
 NS_IMETHODIMP nsLocalFile::InitWithFile(nsILocalFile *aFile)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG(aFile);
   
   nsCOMPtr<nsILocalFileMac> aFileMac(do_QueryInterface(aFile));
   if (!aFileMac)
     return NS_ERROR_UNEXPECTED;
   CFURLRef urlRef;
   nsresult rv = aFileMac->GetCFURL(&urlRef);
   if (NS_FAILED(rv))
     return rv;
   rv = InitWithCFURL(urlRef);
   ::CFRelease(urlRef);
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute PRBool followLinks; */
 NS_IMETHODIMP nsLocalFile::GetFollowLinks(PRBool *aFollowLinks)
 {
   NS_ENSURE_ARG_POINTER(aFollowLinks);
   
   *aFollowLinks = mFollowLinks;
@@ -1477,16 +1607,18 @@ NS_IMETHODIMP nsLocalFile::Load(PRLibrar
     return NS_ERROR_FAILURE;
   
   return NS_OK;
 }
 
 /* readonly attribute PRInt64 diskSpaceAvailable; */
 NS_IMETHODIMP nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   NS_ENSURE_ARG_POINTER(aDiskSpaceAvailable);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
@@ -1502,16 +1634,18 @@ NS_IMETHODIMP nsLocalFile::GetDiskSpaceA
   FSVolumeInfo volumeInfo;  
   err = ::FSGetVolumeInfo(catalogInfo.volume, 0, nsnull, kFSVolInfoSizes,
                           &volumeInfo, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
     
   *aDiskSpaceAvailable = volumeInfo.freeBytes;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void appendRelativePath (in AString relativeFilePath); */
 NS_IMETHODIMP nsLocalFile::AppendRelativePath(const nsAString& relativeFilePath)
 {
   return AppendRelativeNativePath(NS_ConvertUTF16toUTF8(relativeFilePath));
 }
 
@@ -1540,16 +1674,18 @@ NS_IMETHODIMP nsLocalFile::AppendRelativ
     nodeBegin = nodeEnd;
   }
   return NS_OK;
 }
 
 /* attribute ACString persistentDescriptor; */
 NS_IMETHODIMP nsLocalFile::GetPersistentDescriptor(nsACString& aPersistentDescriptor)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
     
   AliasHandle aliasH;
   OSErr err = ::FSNewAlias(nsnull, &fsRef, &aliasH);
   if (err != noErr)
@@ -1561,20 +1697,24 @@ NS_IMETHODIMP nsLocalFile::GetPersistent
    char* buf = PL_Base64Encode((const char*)*aliasH, bytes, nsnull);
    ::DisposeHandle((Handle) aliasH);
    NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
    
    aPersistentDescriptor = buf;
    PR_Free(buf);
 
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetPersistentDescriptor(const nsACString& aPersistentDescriptor)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   if (aPersistentDescriptor.IsEmpty())
     return NS_ERROR_INVALID_ARG;
 
   // Support pathnames as user-supplied descriptors if they begin with '/'
   // or '~'.  These characters do not collide with the base64 set used for
   // encoding alias records.
   char first = aPersistentDescriptor.First();
   if (first == '/' || first == '~')
@@ -1611,21 +1751,25 @@ NS_IMETHODIMP nsLocalFile::SetPersistent
   OSErr err = ::FSResolveAlias(nsnull, (AliasHandle)newHandle, &resolvedFSRef, &changed);
     
   rv = MacErrorMapper(err);
   DisposeHandle(newHandle);
   if (NS_FAILED(rv))
     return rv;
  
   return InitWithFSRef(&resolvedFSRef);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void reveal (); */
 NS_IMETHODIMP nsLocalFile::Reveal()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef             fsRefToReveal;
   AppleEvent        aeEvent = {0, nil};
   AppleEvent        aeReply = {0, nil};
   StAEDesc          aeDirDesc, listElem, myAddressDesc, fileList;
   OSErr             err;
   ProcessSerialNumber   process;
     
   nsresult rv = GetFSRefInternal(fsRefToReveal);
@@ -1657,28 +1801,34 @@ NS_IMETHODIMP nsLocalFile::Reveal()
             }
           }
         }
       }
     }
   }
     
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void launch (); */
 NS_IMETHODIMP nsLocalFile::Launch()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
 
   OSErr err = ::LSOpenFSRef(&fsRef, NULL);
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 //*****************************************************************************
 //  nsLocalFile::nsILocalFileMac
 //*****************************************************************************
 #pragma mark -
 #pragma mark [nsILocalFileMac]
@@ -1690,31 +1840,37 @@ NS_IMETHODIMP nsLocalFile::InitWithCFURL
   
   SetBaseRef(aCFURL);
   return NS_OK;
 }
 
 /* void initWithFSRef ([const] in FSRefPtr aFSRef); */
 NS_IMETHODIMP nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG(aFSRef);
   nsresult rv = NS_ERROR_FAILURE;
   
   CFURLRef newURLRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, aFSRef);
   if (newURLRef) {
     SetBaseRef(newURLRef);
     ::CFRelease(newURLRef);
     rv = NS_OK;
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void initWithFSSpec ([const] in FSSpecPtr aFileSpec); */
 NS_IMETHODIMP nsLocalFile::InitWithFSSpec(const FSSpec *aFileSpec)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG(aFileSpec);
   
   FSRef fsRef;
   OSErr err = ::FSpMakeFSRef(aFileSpec, &fsRef);
   if (err == noErr)
     return InitWithFSRef(&fsRef);
   else if (err == fnfErr) {
     CInfoPBRec  pBlock;
@@ -1740,49 +1896,61 @@ NS_IMETHODIMP nsLocalFile::InitWithFSSpe
     if (err != noErr)
       return MacErrorMapper(err);
     nsresult rv = InitWithFSRef(&fsRef);
     if (NS_FAILED(rv))
       return rv;
     return Append(nsDependentString(unicodeName.unicode, unicodeName.length));  
   }
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void initToAppWithCreatorCode (in OSType aAppCreator); */
 NS_IMETHODIMP nsLocalFile::InitToAppWithCreatorCode(OSType aAppCreator)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   OSErr err = ::LSFindApplicationForInfo(aAppCreator, nsnull, nsnull, &fsRef, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   return InitWithFSRef(&fsRef);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* CFURLRef getCFURL (); */
 NS_IMETHODIMP nsLocalFile::GetCFURL(CFURLRef *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(_retval);
   CFURLRef whichURLRef = mFollowLinks ? mTargetRef : mBaseRef;
   if (whichURLRef)
     ::CFRetain(whichURLRef);
   *_retval = whichURLRef;
   return whichURLRef ? NS_OK : NS_ERROR_FAILURE;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* FSRef getFSRef (); */
 NS_IMETHODIMP nsLocalFile::GetFSRef(FSRef *_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   return GetFSRefInternal(*_retval);
 }
 
 /* FSSpec getFSSpec (); */
 NS_IMETHODIMP nsLocalFile::GetFSSpec(FSSpec *_retval)
-{
+{  
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(_retval);
 
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   OSErr err;
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
@@ -1815,94 +1983,116 @@ NS_IMETHODIMP nsLocalFile::GetFSSpec(FSS
             err = ::FSMakeFSSpec(catalogInfo.volume, catalogInfo.nodeID, hfsName, _retval);        
         }
       }
     }
     ::CFRelease(parentURLRef);
     rv = MacErrorMapper(err);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* readonly attribute PRInt64 fileSizeWithResFork; */
 NS_IMETHODIMP nsLocalFile::GetFileSizeWithResFork(PRInt64 *aFileSizeWithResFork)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aFileSizeWithResFork);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
       
   FSCatalogInfo catalogInfo;
   OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes,
                                  &catalogInfo, nsnull, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
     
   *aFileSizeWithResFork = catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute OSType fileType; */
 NS_IMETHODIMP nsLocalFile::GetFileType(OSType *aFileType)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aFileType);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
   FinderInfo fInfo;  
   OSErr err = ::FSGetFinderInfo(&fsRef, &fInfo, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   *aFileType = fInfo.file.fileType;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetFileType(OSType aFileType)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
     
   OSErr err = ::FSChangeCreatorType(&fsRef, 0, aFileType);
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* attribute OSType fileCreator; */
 NS_IMETHODIMP nsLocalFile::GetFileCreator(OSType *aFileCreator)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG_POINTER(aFileCreator);
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
   FinderInfo fInfo;  
   OSErr err = ::FSGetFinderInfo(&fsRef, &fInfo, nsnull, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
   *aFileCreator = fInfo.file.fileCreator;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetFileCreator(OSType aFileCreator)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
     
   OSErr err = ::FSChangeCreatorType(&fsRef, aFileCreator, 0);
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void setFileTypeAndCreatorFromMIMEType (in string aMIMEType); */
 NS_IMETHODIMP nsLocalFile::SetFileTypeAndCreatorFromMIMEType(const char *aMIMEType)
 {
   // XXX - This should be cut from the API. Would create an evil dependency.
   NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
   return NS_ERROR_NOT_IMPLEMENTED;
@@ -1914,16 +2104,18 @@ NS_IMETHODIMP nsLocalFile::SetFileTypeAn
   // XXX - This should be cut from the API. Would create an evil dependency.
   NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 /* void launchWithDoc (in nsILocalFile aDocToLoad, in boolean aLaunchInBackground); */
 NS_IMETHODIMP nsLocalFile::LaunchWithDoc(nsILocalFile *aDocToLoad, PRBool aLaunchInBackground)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   PRBool isExecutable;
   nsresult rv = IsExecutable(&isExecutable);
   if (NS_FAILED(rv))
     return rv;
   if (!isExecutable)
     return NS_ERROR_FILE_EXECUTION_FAILED;
 
   FSRef appFSRef, docFSRef;
@@ -1952,21 +2144,25 @@ NS_IMETHODIMP nsLocalFile::LaunchWithDoc
   }
   thelaunchSpec.launchFlags = theLaunchFlags;
 
   OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, NULL);
   if (err != noErr)
     return MacErrorMapper(err);
 
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* void openDocWithApp (in nsILocalFile aAppToOpenWith, in boolean aLaunchInBackground); */
 NS_IMETHODIMP nsLocalFile::OpenDocWithApp(nsILocalFile *aAppToOpenWith, PRBool aLaunchInBackground)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv;
   OSErr err;
 
   FSRef docFSRef, appFSRef;
   rv = GetFSRefInternal(docFSRef);
   if (NS_FAILED(rv))
     return rv;
 
@@ -2009,21 +2205,25 @@ NS_IMETHODIMP nsLocalFile::OpenDocWithAp
   thelaunchSpec.itemRefs = &docFSRef;
   thelaunchSpec.launchFlags = theLaunchFlags;
 
   err = ::LSOpenFromRefSpec(&thelaunchSpec, NULL);
   if (err != noErr)
     return MacErrorMapper(err);
 
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean isPackage (); */
 NS_IMETHODIMP nsLocalFile::IsPackage(PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG(_retval);
   *_retval = PR_FALSE;
   
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
 
@@ -2046,16 +2246,18 @@ NS_IMETHODIMP nsLocalFile::IsPackage(PRB
         if (extPtr) {
           if ((nsCRT::strcasecmp(extPtr, ".app") == 0))
             *_retval = PR_TRUE;
         }
       }
     }
   }
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetBundleDisplayName(nsAString& outBundleName)
 {
   PRBool isPackage = PR_FALSE;
   nsresult rv = IsPackage(&isPackage);
   if (NS_FAILED(rv) || !isPackage)
@@ -2075,58 +2277,68 @@ nsLocalFile::GetBundleDisplayName(nsAStr
     outBundleName = name;
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetBundleIdentifier(nsACString& outBundleIdentifier)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv = NS_ERROR_FAILURE;
 
   CFURLRef urlRef;
   if (NS_SUCCEEDED(GetCFURL(&urlRef))) {
     CFBundleRef bundle = ::CFBundleCreate(NULL, urlRef);
     if (bundle) {
       CFStringRef bundleIdentifier = ::CFBundleGetIdentifier(bundle);
       if (bundleIdentifier)
         rv = CFStringReftoUTF8(bundleIdentifier, outBundleIdentifier);
 
       ::CFRelease(bundle);
     }
     ::CFRelease(urlRef);
   }
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 //*****************************************************************************
 //  nsLocalFile Methods
 //*****************************************************************************
 #pragma mark -
 #pragma mark [Protected Methods]
 
 nsresult nsLocalFile::SetBaseRef(CFURLRef aCFURLRef)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   NS_ENSURE_ARG(aCFURLRef);
   
   ::CFRetain(aCFURLRef);
   if (mBaseRef)
     ::CFRelease(mBaseRef);
   mBaseRef = aCFURLRef;
 
   mFollowLinksDirty = PR_TRUE;  
   UpdateTargetRef();
   mCachedFSRefValid = PR_FALSE;
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsLocalFile::UpdateTargetRef()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
   
   if (mFollowLinksDirty) {
     if (mTargetRef) {
       ::CFRelease(mTargetRef);
       mTargetRef = nsnull;
     }
@@ -2144,56 +2356,68 @@ nsresult nsLocalFile::UpdateTargetRef()
           if (!mTargetRef)
             return NS_ERROR_FAILURE;
         }
       }
       mFollowLinksDirty = PR_FALSE;
     }
   }
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsLocalFile::GetFSRefInternal(FSRef& aFSRef, PRBool bForceUpdateCache)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   if (bForceUpdateCache || !mCachedFSRefValid) {
     mCachedFSRefValid = PR_FALSE;
     CFURLRef whichURLRef = mFollowLinks ? mTargetRef : mBaseRef;
     NS_ENSURE_TRUE(whichURLRef, NS_ERROR_NULL_POINTER);
     if (::CFURLGetFSRef(whichURLRef, &mCachedFSRef))
       mCachedFSRefValid = PR_TRUE;
   }
   if (mCachedFSRefValid) {
     aFSRef = mCachedFSRef;
     return NS_OK;
   }
   // CFURLGetFSRef only returns a Boolean for success,
   // so we have to assume what the error was. This is
   // the only probable cause.
   return NS_ERROR_FILE_NOT_FOUND;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsLocalFile::GetPathInternal(nsACString& path)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv = NS_ERROR_FAILURE;
   
   CFURLRef whichURLRef = mFollowLinks ? mTargetRef : mBaseRef;
   NS_ENSURE_TRUE(whichURLRef, NS_ERROR_NULL_POINTER);
    
   CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(whichURLRef, kCFURLPOSIXPathStyle);
   if (pathStrRef) {
     rv = CFStringReftoUTF8(pathStrRef, path);
     ::CFRelease(pathStrRef);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsLocalFile::CopyInternal(nsIFile* aParentDir,
                                    const nsAString& newName,
                                    PRBool followLinks)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   StFollowLinksState srcFollowState(*this, followLinks);
 
   nsresult rv;
   OSErr err;
   FSRef srcFSRef, newFSRef;
@@ -2232,16 +2456,18 @@ nsresult nsLocalFile::CopyInternal(nsIFi
     return rv;
 
   err =
    ::FSCopyObject(&srcFSRef, &destFSRef, newName.Length(),
                   newName.Length() ? PromiseFlatString(newName).get() : NULL,
                   0, kFSCatInfoNone, false, false, NULL, NULL, &newFSRef);
 
   return MacErrorMapper(err);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 const PRInt64 kMillisecsPerSec = 1000LL;
 const PRInt64 kUTCDateTimeFractionDivisor = 65535LL;
 
 PRInt64 nsLocalFile::HFSPlustoNSPRTime(const UTCDateTime& utcTime)
 {
   // Start with seconds since Jan. 1, 1904 GMT
@@ -2262,50 +2488,58 @@ void nsLocalFile::NSPRtoHFSPlusTime(PRIn
   PRInt64 seconds = (nsprTime / kMillisecsPerSec) + kJanuaryFirst1970Seconds;
   utcTime.highSeconds = (UInt16)((PRUint64)seconds >> 32);
   utcTime.lowSeconds = (UInt32)seconds;
   utcTime.fraction = (UInt16)((fraction * kUTCDateTimeFractionDivisor) / kMillisecsPerSec);
 }
 
 nsresult nsLocalFile::CFStringReftoUTF8(CFStringRef aInStrRef, nsACString& aOutStr)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv = NS_ERROR_FAILURE;
   CFIndex usedBufLen, inStrLen = ::CFStringGetLength(aInStrRef);
   CFIndex charsConverted = ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen),
                               kCFStringEncodingUTF8, 0, PR_FALSE, nsnull, 0, &usedBufLen);
   if (charsConverted == inStrLen) {
     aOutStr.SetLength(usedBufLen);
     if (aOutStr.Length() != (unsigned int)usedBufLen)
       return NS_ERROR_OUT_OF_MEMORY;
     UInt8 *buffer = (UInt8*) aOutStr.BeginWriting();
 
     ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen),
                        kCFStringEncodingUTF8, 0, false, buffer, usedBufLen, &usedBufLen);
     rv = NS_OK;
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // nsIHashable
 
 NS_IMETHODIMP
 nsLocalFile::Equals(nsIHashable* aOther, PRBool *aResult)
 {
     return EqualsInternal(aOther, PR_FALSE, aResult);
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetHashCode(PRUint32 *aResult)
 {
+    NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
     CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(mBaseRef, kCFURLPOSIXPathStyle);
     nsCAutoString path;
     CFStringReftoUTF8(pathStrRef, path);
     ::CFRelease(pathStrRef);
     *aResult = HashString(path);
     return NS_OK;
+
+    NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 //*****************************************************************************
 //  Global Functions
 //*****************************************************************************
 #pragma mark -
 #pragma mark [Global Functions]
 
@@ -2430,16 +2664,18 @@ static nsresult MacErrorMapper(OSErr inE
             outErr = NS_ERROR_FAILURE;
             break;
     }
     return outErr;
 }
 
 static OSErr FindRunningAppBySignature(OSType aAppSig, ProcessSerialNumber& outPsn)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
   ProcessInfoRec info;
   OSErr err = noErr;
   
   outPsn.highLongOfPSN = 0;
   outPsn.lowLongOfPSN  = kNoProcess;
   
   while (PR_TRUE)
   {
@@ -2454,26 +2690,30 @@ static OSErr FindRunningAppBySignature(O
     err = ::GetProcessInformation(&outPsn, &info);
     if (err != noErr)
       return err;
     
     if (info.processSignature == aAppSig)
       return noErr;
   }
   return procNotFound;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(procNotFound);
 }
 
 // Convert a UTF-8 string to a UTF-16 string while normalizing to
 // Normalization Form C (composed Unicode). We need this because
 // Mac OS X file system uses NFD (Normalization Form D : decomposed Unicode)
 // while most other OS', server-side programs usually expect NFC.
 
 typedef void (*UnicodeNormalizer) (CFMutableStringRef, CFStringNormalizationForm);
 static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult)
 {
+    NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
     static PRBool sChecked = PR_FALSE;
     static UnicodeNormalizer sUnicodeNormalizer = NULL;
 
     // CFStringNormalize was not introduced until Mac OS 10.2
     if (!sChecked) {
         CFBundleRef carbonBundle =
             CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon"));
         if (carbonBundle)
@@ -2514,9 +2754,11 @@ static void CopyUTF8toUTF16NFC(const nsA
         if (!buffer.SetLength(length))
             CopyUTF8toUTF16(aSrc, aResult);
         else {
             CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements());
             aResult.Assign(buffer.Elements(), length);
         }
     }
     CFRelease(inStr);
+
+    NS_OBJC_END_TRY_ABORT_BLOCK;
 }