Toll-free bridge Error to CPException. Add rhinoException in objj_exception for better error reporting.

This commit is contained in:
aburkhalter
2009-12-19 03:49:22 -08:00
committed by tlrobinson
parent a9bc949679
commit deed92cff7
3 changed files with 20 additions and 14 deletions
+10 -7
View File
@@ -92,7 +92,7 @@ if (input == nil)
if (self)
{
name = aName;
reason = aReason;
message = aReason;
userInfo = aUserInfo;
}
@@ -112,7 +112,7 @@ if (input == nil)
*/
- (CPString)reason
{
return reason;
return message;
}
/*!
@@ -128,7 +128,7 @@ if (input == nil)
*/
- (CPString)description
{
return reason;
return message;
}
/*!
@@ -145,7 +145,7 @@ if (input == nil)
- (id)copy
{
return [[self class] exceptionWithName:name reason:reason userInfo:userInfo];
return [[self class] exceptionWithName:name reason:message userInfo:userInfo];
}
@end
@@ -168,7 +168,7 @@ var CPExceptionNameKey = "CPExceptionNameKey",
if (self)
{
name = [aCoder decodeObjectForKey:CPExceptionNameKey];
reason = [aCoder decodeObjectForKey:CPExceptionReasonKey];
message = [aCoder decodeObjectForKey:CPExceptionReasonKey];
userInfo = [aCoder decodeObjectForKey:CPExceptionUserInfoKey];
}
@@ -182,13 +182,16 @@ var CPExceptionNameKey = "CPExceptionNameKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:name forKey:CPExceptionNameKey];
[aCoder encodeObject:reason forKey:CPExceptionReasonKey];
[aCoder encodeObject:message forKey:CPExceptionReasonKey];
[aCoder encodeObject:userInfo forKey:CPExceptionUserInfoKey];
}
@end
objj_exception.prototype.isa = CPException;
// toll-free bridge Error to CPException
// [CPException alloc] uses an objj_exception, which is a subclass of Error
Error.prototype.isa = CPException;
[CPException initialize];
function _CPRaiseInvalidAbstractInvocation(anObject, aSelector)
+8 -5
View File
@@ -25,15 +25,18 @@ var OBJJ_EXCEPTION_OUTPUT_STREAM = NULL;
function objj_exception(aName, aReason, aUserInfo)
{
this.name = aName;
this.reason = aReason;
this.message = aReason;
this.userInfo = aUserInfo;
this.__address = _objj_generateObjectHash();
// add rhinoException to get better stack traces
if (typeof Packages !== "undefined" && Packages && Packages.org)
this.rhinoException = Packages.org.mozilla.javascript.JavaScriptException(this, null, 0);
}
objj_exception.prototype.toString = function()
{
return this.reason;
}
// make objj_exception a subclass of Error
// later we toll-free bridge Error to CPException
objj_exception.prototype = new Error();
function objj_exception_throw(anException)
{
+2 -2
View File
@@ -283,7 +283,7 @@ function descriptionWithoutEntity(aString)
[self assert:[_set lastIndex] equals:19];
[self assert:[[CPIndexSet indexSet] lastIndex] equals:CPNotFound];
}
/*
- (void)testAddSpeed
{
var startTime = [CPDate date];
@@ -296,7 +296,7 @@ function descriptionWithoutEntity(aString)
print([startTime timeIntervalSinceNow]);
//[self assertTrue: ABS([startTime timeIntervalSinceNow]) < 2];
}
*/
- (void)testIndexGreaterThanIndex
{
[self assert:[_set indexGreaterThanIndex:5] equals:10];