Improve output: distinguish between failed assertions (failures) and unexpected exceptions (errors), and print a filtered stack trace for any exception.

This commit is contained in:
jeb228 2010-01-29 22:13:57 +00:00
commit 4f2e303079
1839 changed files with 235630 additions and 0 deletions

View file

@ -0,0 +1,15 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.rpc.Deferred");
dojo.require("dojo.Deferred");
dojo.rpc.Deferred = dojo.Deferred;
dojo.rpc.Deferred.prototype = dojo.Deferred.prototype;

View file

@ -0,0 +1,41 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.rpc.JotService");
dojo.require("dojo.rpc.RpcService");
dojo.require("dojo.rpc.JsonService");
dojo.require("dojo.json");
dojo.rpc.JotService = function(){
this.serviceUrl = "/_/jsonrpc";
}
dojo.inherits(dojo.rpc.JotService, dojo.rpc.JsonService);
dojo.lang.extend(dojo.rpc.JotService, {
bind: function(method, parameters, deferredRequestHandler, url){
dojo.io.bind({
url: url||this.serviceUrl,
content: {
json: this.createRequest(method, parameters)
},
method: "POST",
mimetype: "text/json",
load: this.resultCallback(deferredRequestHandler),
error: this.errorCallback(deferredRequestHandler),
preventCache: true
});
},
createRequest: function(method, params){
var req = { "params": params, "method": method, "id": this.lastSubmissionId++ };
return dojo.json.serialize(req);
}
});

View file

@ -0,0 +1,103 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.rpc.JsonService");
dojo.require("dojo.rpc.RpcService");
dojo.require("dojo.io.*");
dojo.require("dojo.json");
dojo.require("dojo.lang");
dojo.rpc.JsonService = function(args){
// passing just the URL isn't terribly useful. It's expected that at
// various times folks will want to specify:
// - just the serviceUrl (for use w/ remoteCall())
// - the text of the SMD to evaluate
// - a raw SMD object
// - the SMD URL
if(args){
if(dojo.lang.isString(args)){
// we assume it's an SMD file to be processed, since this was the
// earlier function signature
// FIXME: also accept dojo.uri.Uri objects?
this.connect(args);
}else{
// otherwise we assume it's an arguments object with the following
// (optional) properties:
// - serviceUrl
// - strictArgChecks
// - smdUrl
// - smdStr
// - smdObj
if(args["smdUrl"]){
this.connect(args.smdUrl);
}
if(args["smdStr"]){
this.processSmd(dj_eval("("+args.smdStr+")"));
}
if(args["smdObj"]){
this.processSmd(args.smdObj);
}
if(args["serviceUrl"]){
this.serviceUrl = args.serviceUrl;
}
if(typeof args["strictArgChecks"] != "undefined"){
this.strictArgChecks = args.strictArgChecks;
}
}
}
}
dojo.inherits(dojo.rpc.JsonService, dojo.rpc.RpcService);
dojo.lang.extend(dojo.rpc.JsonService, {
bustCache: false,
contentType: "application/json-rpc",
lastSubmissionId: 0,
callRemote: function(method, params){
var deferred = new dojo.rpc.Deferred();
this.bind(method, params, deferred);
return deferred;
},
bind: function(method, parameters, deferredRequestHandler, url){
dojo.io.bind({
url: url||this.serviceUrl,
postContent: this.createRequest(method, parameters),
method: "POST",
contentType: this.contentType,
mimetype: "text/json",
load: this.resultCallback(deferredRequestHandler),
preventCache:this.bustCache
});
},
createRequest: function(method, params){
var req = { "params": params, "method": method, "id": ++this.lastSubmissionId };
var data = dojo.json.serialize(req);
dojo.debug("JsonService: JSON-RPC Request: " + data);
return data;
},
parseResults: function(obj){
if(!obj){ return; }
if(obj["Result"]||obj["result"]){
return obj["result"]||obj["Result"];
}else if(obj["ResultSet"]){
return obj["ResultSet"];
}else{
return obj;
}
}
});

View file

@ -0,0 +1,116 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.rpc.RpcService");
dojo.require("dojo.io.*");
dojo.require("dojo.json");
dojo.require("dojo.lang.func");
dojo.require("dojo.rpc.Deferred");
dojo.rpc.RpcService = function(url){
// summary
// constructor for rpc base class
if(url){
this.connect(url);
}
}
dojo.lang.extend(dojo.rpc.RpcService, {
strictArgChecks: true,
serviceUrl: "",
parseResults: function(obj){
// summary
// parse the results coming back from an rpc request.
// this base implementation, just returns the full object
// subclasses should parse and only return the actual results
return obj;
},
errorCallback: function(/* dojo.rpc.Deferred */ deferredRequestHandler){
// summary
// create callback that calls the Deferres errback method
return function(type, obj, e){
deferredRequestHandler.errback(e);
}
},
resultCallback: function(/* dojo.rpc.Deferred */ deferredRequestHandler){
// summary
// create callback that calls the Deferred's callback method
var tf = dojo.lang.hitch(this,
function(type, obj, e){
var results = this.parseResults(obj||e);
deferredRequestHandler.callback(results);
}
);
return tf;
},
generateMethod: function(/*string*/ method, /*array*/ parameters, /*string*/ url){
// summary
// generate the local bind methods for the remote object
return dojo.lang.hitch(this, function(){
var deferredRequestHandler = new dojo.rpc.Deferred();
// if params weren't specified, then we can assume it's varargs
if( (this.strictArgChecks) &&
(parameters != null) &&
(arguments.length != parameters.length)
){
// put error stuff here, no enough params
dojo.raise("Invalid number of parameters for remote method.");
} else {
this.bind(method, arguments, deferredRequestHandler, url);
}
return deferredRequestHandler;
});
},
processSmd: function(/*json*/ object){
// summary
// callback method for reciept of a smd object. Parse the smd and
// generate functions based on the description
dojo.debug("RpcService: Processing returned SMD.");
if(object.methods){
dojo.lang.forEach(object.methods, function(m){
if(m && m["name"]){
dojo.debug("RpcService: Creating Method: this.", m.name, "()");
this[m.name] = this.generateMethod( m.name,
m.parameters,
m["url"]||m["serviceUrl"]||m["serviceURL"]);
if(dojo.lang.isFunction(this[m.name])){
dojo.debug("RpcService: Successfully created", m.name, "()");
}else{
dojo.debug("RpcService: Failed to create", m.name, "()");
}
}
}, this);
}
this.serviceUrl = object.serviceUrl||object.serviceURL;
dojo.debug("RpcService: Dojo RpcService is ready for use.");
},
connect: function(/*String*/ smdUrl){
// summary
// connect to a remote url and retrieve a smd object
dojo.debug("RpcService: Attempting to load SMD document from:", smdUrl);
dojo.io.bind({
url: smdUrl,
mimetype: "text/json",
load: dojo.lang.hitch(this, function(type, object, e){ return this.processSmd(object); }),
sync: true
});
}
});

View file

@ -0,0 +1,55 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.rpc.YahooService");
dojo.require("dojo.rpc.RpcService");
dojo.require("dojo.rpc.JsonService");
dojo.require("dojo.json");
dojo.require("dojo.uri.*");
dojo.require("dojo.io.ScriptSrcIO");
dojo.rpc.YahooService = function(appId){
this.appId = appId;
if(!appId){
this.appId = "dojotoolkit";
dojo.debug( "please initializae the YahooService class with your own",
"application ID. Using the default may cause problems during",
"deployment of your application");
}
this.connect(dojo.uri.dojoUri("src/rpc/yahoo.smd"));
this.scrictArgChecks = false;
}
dojo.inherits(dojo.rpc.YahooService, dojo.rpc.JsonService);
dojo.lang.extend(dojo.rpc.YahooService, {
strictArgChecks: false,
bind: function(method, parameters, deferredRequestHandler, url){
var params = parameters;
if( (dojo.lang.isArrayLike(parameters))&&
(parameters.length == 1)){
params = parameters[0];
}
params.output = "json";
params.appid= this.appId;
dojo.io.bind({
url: url||this.serviceUrl,
transport: "ScriptSrcTransport",
// FIXME: need to get content interpolation fixed
content: params,
jsonParamName: "callback",
mimetype: "text/json",
load: this.resultCallback(deferredRequestHandler),
error: this.errorCallback(deferredRequestHandler),
preventCache: true
});
}
});

View file

@ -0,0 +1,14 @@
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.kwCompoundRequire({
common: ["dojo.rpc.JsonService", false, false]
});
dojo.provide("dojo.rpc.*");

View file

@ -0,0 +1,263 @@
{
"SMDVersion":".1",
"objectName":"yahoo",
"serviceType":"JSON-P",
"methods":[
//
// MAPS
//
{
// http://developer.yahoo.com/maps/rest/V1/mapImage.html
"name":"mapImage",
"serviceURL": "http://api.local.yahoo.com/MapsService/V1/mapImage",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"image_type", "type":"STRING" },
{ "name":"image_width", "type":"INTEGER" },
{ "name":"image_height", "type":"INTEGER" },
{ "name":"zoom", "type":"INTEGER" },
{ "name":"radius", "type":"INTEGER" }
]
},
{
// http://developer.yahoo.com/traffic/rest/V1/index.html
"name":"trafficData",
"serviceURL": "http://api.local.yahoo.com/MapsService/V1/trafficData",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"severity", "type":"INTEGER" },
{ "name":"include_map", "type":"INTEGER" },
{ "name":"image_type", "type":"STRING" },
{ "name":"image_width", "type":"INTEGER" },
{ "name":"image_height", "type":"INTEGER" },
{ "name":"zoom", "type":"INTEGER" },
{ "name":"radius", "type":"INTEGER" }
]
},
/*
// Yahoo's geocoding service is f'd for JSON and Y! advises that it
// may not be returning
{
// http://developer.yahoo.com/maps/rest/V1/geocode.html
"name":"geocode",
"serviceURL": "http://api.local.yahoo.com/MapsService/V1/geocode",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" }
]
},
*/
//
// LOCAL SEARCH
//
{
// http://developer.yahoo.com/search/local/V3/localSearch.html
"name":"localSearch",
"serviceURL": "http://api.local.yahoo.com/LocalSearchService/V3/localSearch",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"listing_id", "type":"STRING" },
{ "name":"sort", "type":"STRING" }, // "relevence", "title", "distance", or "rating"
{ "name":"start", "type":"INTEGER" },
{ "name":"radius", "type":"FLOAT" },
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"category", "type":"INTEGER" },
{ "name":"omit_category", "type":"INTEGER" },
{ "name":"minimum_rating", "type":"INTEGER" }
]
},
//
// WEB SEARCH
//
// NOTE: contextual search and term extraction are not stubbed out
// becaues I'm not sure if we can POST via script src inclusion method
{
// http://developer.yahoo.com/search/web/V1/webSearch.html
"name":"webSearch",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/webSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all"
{ "name":"region", "type":"STRING" }, // defaults to "us"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls"
{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
{ "name":"similar_ok", "type":"INTEGER" }, // defaults to null
{ "name":"language", "type":"STRING" }, // defaults to null
{ "name":"country", "type":"STRING" }, // defaults to null
{ "name":"site", "type":"STRING" }, // defaults to null
{ "name":"subscription", "type":"STRING" }, // defaults to null
{ "name":"license", "type":"STRING" } // defaults to "any"
]
},
{
// http://developer.yahoo.com/search/web/V1/spellingSuggestion.html
"name":"spellingSuggestion",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion",
"parameters":[ { "name":"query", "type":"STRING" } ]
},
{
// http://developer.yahoo.com/search/web/V1/relatedSuggestion.html
"name":"spellingSuggestion",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/relatedSuggestion",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"results", "type":"INTEGER" } // 1-50, defaults to 10
]
},
//
// IMAGE SEARCH
//
{
// http://developer.yahoo.com/search/image/V1/imageSearch.html
"name":"imageSearch",
"serviceURL": "http://api.search.yahoo.com/ImageSearchService/V1/imageSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"format", "type":"STRING" }, // defaults to "any", can be "bmp", "gif", "jpeg", or "png"
{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
{ "name":"coloration", "type":"STRING" }, // "any", "color", or "bw"
{ "name":"site", "type":"STRING" } // defaults to null
]
},
//
// SITE EXPLORER
//
{
// http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html
"name":"inlinkData",
"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/inlinkData",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"entire_site", "type":"INTEGER" }, // defaults to null
{ "name":"omit_inlinks", "type":"STRING" }, // "domain" or "subdomain", defaults to null
{ "name":"results", "type":"INTEGER" }, // defaults to 50
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"site", "type":"STRING" } // defaults to null
]
},
{
// http://developer.yahoo.com/search/siteexplorer/V1/pageData.html
"name":"pageData",
"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/pageData",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"domain_only", "type":"INTEGER" }, // defaults to null
{ "name":"results", "type":"INTEGER" }, // defaults to 50
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"site", "type":"STRING" } // defaults to null
]
},
//
// MUSIC SEARCH
//
{
// http://developer.yahoo.com/search/audio/V1/artistSearch.html
"name":"artistSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/artistSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/albumSearch.html
"name":"albumSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/albumSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"album", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/songSearch.html
"name":"songSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"album", "type":"STRING" },
{ "name":"albumid", "type":"STRING" },
{ "name":"song", "type":"STRING" },
{ "name":"songid", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/songDownloadLocation.html
"name":"songDownloadLocation",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songDownloadLocation",
"parameters":[
{ "name":"songid", "type":"STRING" },
// "source" can contain:
// audiolunchbox artistdirect buymusic dmusic
// emusic epitonic garageband itunes yahoo
// livedownloads mp34u msn musicmatch mapster passalong
// rhapsody soundclick theweb
{ "name":"source", "type":"STRING" },
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
//
// NEWS SEARCH
//
{
// http://developer.yahoo.com/search/news/V1/newsSearch.html
"name":"newsSearch",
"serviceURL": "http://api.search.yahoo.com/NewsSearchService/V1/newsSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"sort", "type":"STRING" }, // "rank" or "date"
{ "name":"language", "type":"STRING" }, // defaults to null
{ "name":"site", "type":"STRING" } // defaults to null
]
}
/*
{
//
"name":"",
"serviceURL": "",
"parameters":[
{ "name":"street", "type":"STRING" },
]
}
*/
]
}