stack-trace

Expand PHP Stack Trace Arguments

独自空忆成欢 提交于 2019-12-06 02:16:10
问题 On a stack trace returned from a PHP application in development, long string arguments to a function are truncated when display on the error page: Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO "tb...', Array) How can I expand the query argument so the full text is visible? The server is running PHP 5.3.3. 回答1: Use debug_backtrace instead. It will give you the whole trace and doesn't trim arguments as far as I know. On a second thought: You might get away with it by using try

Can you get Method name that threw Exception?

让人想犯罪 __ 提交于 2019-12-06 00:58:27
Is there a C# method that returns to the upper-most caller, the Name of MY Method that threw an exception, even if the actual exception was thrown by another (e.g. database driver errors when my method calls it) ? Caller -> MyMethod -> DbDriver(error) I want "MyMethod", not "DbDriver" I'd rather not re-throw exceptions all the way up the chain. My current kludge, is to iterate through the StackTrace frames, and parse out my Method using MethodBase.GetCurrentMethod().DeclaringType . Is there a built-in method to get this information or a more elegant solution? Thanks! Use Exception.TargetSite

Calling C function which takes no parameters with parameters

人走茶凉 提交于 2019-12-06 00:28:14
I have some weird question about probably undefined behavior between C calling convention and 64/32 bits compilation. First here is my code: int f() { return 0; } int main() { int x = 42; return f(x); } As you can see I am calling f with an argument while f takes no parameters. My first question was does this argument is really given to f while calling it. The mysterious lines After a little objdump I obtained curious results. While passing x as argument of f: 00000000004004b6 <f>: 4004b6: 55 push %rbp 4004b7: 48 89 e5 mov %rsp,%rbp 4004ba: b8 00 00 00 00 mov $0x0,%eax 4004bf: 5d pop %rbp

Method for runtime comparison of two programs' objects

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 17:39:35
I am working through a particular type of code testing that is rather nettlesome and could be automated, yet I'm not sure of the best practices. Before describing the problem, I want to make clear that I'm looking for the appropriate terminology and concepts, so that I can read more about how to implement it. Suggestions on best practices are welcome, certainly, but my goal is specific: what is this kind of approach called? In the simplest case, I have two programs that take in a bunch of data, produce a variety of intermediate objects, and then return a final result. When tested end-to-end,

Getting the Exception object in a try..catch to include FULL stacktrace, currently its truncated

99封情书 提交于 2019-12-05 17:38:05
can anyone help? I am trying to get the full stacktrace when within a catch of try..catch. Currently its truncated to include only the current method where the error is.... Let me explain.. Currently i my stacktrace includes the method "Third" where the error happens but First and Second isn't included, i believe this is by design. private void First() { this.Second(); } private void Second() { this.Third(); } private void Third() { try { throw new SystemException("ERROR HERE!"); } catch (Exception ex) { // I WILL LOG THE EXCEPTION object "EX" here ! but ex.StackTrace is truncated! } } I have

Getting local variables

一个人想着一个人 提交于 2019-12-05 12:53:20
When getting a stacktrace as error report from an application that is already deployed, it would be helpful to also get the actual variable values to reconstruct the system's state at the point before the exception was thrown. Is anything like that feasible in Java and how could one do that? Cheers, Max I'm pretty sure you cannot get the local variables in the stacktrace as the output is built from instance of StackTraceElement which only contains, the class, the file, the method and the line number (see http://download.oracle.com/javase/6/docs/api/java/lang/StackTraceElement.html ). Have a

How do you write a full stack trace to the log?

为君一笑 提交于 2019-12-05 12:51:23
问题 I was catching an exception and trying to write the stack trace to the logs like this: log.warn(e.getMessage()); But all it said was null So I changed it to log.warn(e.toString()); And now it says only java.lang.NullPointerException How do I write the full stack trace to the log so I can see where this Exception is being generated in the app? 回答1: Usually: log.warn("message", e); But it depends on your logging framework too. 回答2: You can use logger.log(Level.WARN, "logged exception", ex); or

Requesting a stack trace for a Java ThreadInfo?

感情迁移 提交于 2019-12-05 11:22:58
I have an application that calls getStackTrace() on a java.lang.management.ThreadInfo object, but the StackTraceElement array produced by the invocation is zero length. Inspecting the Javadoc shows this (emphasis mine): public StackTraceElement[] getStackTrace() Returns the stack trace of the thread associated with this ThreadInfo. If no stack trace was requested for this thread info, this method will return a zero-length array . If the returned array is of non-zero length then the first element of the array represents the top of the stack, which is the most recent method invocation in the

How to specify a “caused by” in a JavaScript Error?

最后都变了- 提交于 2019-12-05 10:54:45
问题 In my NodeJS program, I parse some user JSON file. So I use : this.config = JSON.parse(fs.readFileSync(path)); The problem is that if the json file is not correctly formated, the error thrown is like: undefined:55 }, ^ SyntaxError: Unexpected token } at Object.parse (native) at new MyApp (/path/to/docker/lib/node_modules/myApp/lib/my-app.js:30:28) ... As it is not really user friendly I would like to throw an Error specifying some user friendly message (like "your config file is not well

Getting stack traces in Perl? [duplicate]

老子叫甜甜 提交于 2019-12-05 09:34:53
问题 This question already has answers here : How can I get a call stack listing in Perl? (7 answers) Closed 2 years ago . How do I get stack traces in Perl? 回答1: There are many useful, core and CPAN based tools to generate a stack trace (as other answers illustrate.) However, if you want to roll your own, check out the caller builtin. You can use this to walk down the stack and see exactly what's happening. 回答2: Carp::confess (from use Carp; ) will give you a full stack trace as part of the error