1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include <Foundation/Foundation.h>
10 #include "mozilla/MacStringHelpers.h"
11 #include "mozilla/Unused.h"
13 void GetObjCExceptionInfo(void* inException, nsACString& outString) {
14 NSException* e = (NSException*)inException;
16 NSString* name = [e name];
17 NSString* reason = [e reason];
18 NSArray* stackAddresses = [e callStackReturnAddresses];
20 outString.AssignLiteral("\nObj-C Exception data:\n");
21 outString.Append([name UTF8String]);
22 outString.AppendLiteral(": ");
23 outString.Append([reason UTF8String]);
24 outString.AppendLiteral("\n\nThrown at stack:\n");
25 for (NSNumber* address in stackAddresses) {
26 outString.AppendPrintf("0x%lx\n", [address unsignedIntegerValue]);
28 outString.AppendLiteral("\n");