Better failure message when something is thrown that's not an error
Change from 'undefined : undefined' to '<thing that was thrown> thrown' Pointed out by @charleshansen
This commit is contained in:
@@ -1129,9 +1129,13 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
getJasmineRequireObj().ExceptionFormatter = function() {
|
||||
function ExceptionFormatter() {
|
||||
this.message = function(error) {
|
||||
var message = error.name +
|
||||
': ' +
|
||||
error.message;
|
||||
var message = '';
|
||||
|
||||
if (error.name && error.message) {
|
||||
message += error.name + ': ' + error.message;
|
||||
} else {
|
||||
message += error.toString() + ' thrown';
|
||||
}
|
||||
|
||||
if (error.fileName || error.sourceURL) {
|
||||
message += " in " + (error.fileName || error.sourceURL);
|
||||
|
||||
@@ -35,7 +35,14 @@ describe("ExceptionFormatter", function() {
|
||||
message = exceptionFormatter.message(sampleV8);
|
||||
|
||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
||||
});
|
||||
|
||||
it("formats thrown exceptions that aren't errors", function() {
|
||||
var thrown = "crazy error",
|
||||
exceptionFormatter = new j$.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(thrown);
|
||||
|
||||
expect(message).toEqual("crazy error thrown");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
getJasmineRequireObj().ExceptionFormatter = function() {
|
||||
function ExceptionFormatter() {
|
||||
this.message = function(error) {
|
||||
var message = error.name +
|
||||
': ' +
|
||||
error.message;
|
||||
var message = '';
|
||||
|
||||
if (error.name && error.message) {
|
||||
message += error.name + ': ' + error.message;
|
||||
} else {
|
||||
message += error.toString() + ' thrown';
|
||||
}
|
||||
|
||||
if (error.fileName || error.sourceURL) {
|
||||
message += " in " + (error.fileName || error.sourceURL);
|
||||
|
||||
Reference in New Issue
Block a user