| |
| /* |
| * weinre is available under *either* the terms of the modified BSD license *or* the |
| * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. |
| * |
| * Copyright (c) 2010, 2011 IBM Corporation |
| */ |
| |
| requireClass ./StackTrace |
| |
| //----------------------------------------------------------------------------- |
| class Ex(args, message) |
| if (!args || !args.callee) { |
| throw Ex(arguments, "first parameter must be an Arguments object") |
| } |
| |
| StackTrace.dump(args) |
| |
| if (message instanceof Error) { |
| message = "threw error: " + message |
| } |
| |
| return new Error(prefix(args, message)) |
| |
| //----------------------------------------------------------------------------- |
| function prefix(args, string) |
| if (args.callee.signature) return args.callee.signature + ": " + string |
| if (args.callee.displayName) return args.callee.displayName + ": " + string |
| if (args.callee.name) return args.callee.name + ": " + string |
| return "<anonymous>" + ": " + string |