Cappuccino cryptic [undefined] errors - cappuccino

i get this kind of error in cappuccino
TypeError: Result of expression '_2b' [undefined] is not an object.
TypeError: Result of expression '_40' [undefined] is not an object.
I can't think of what they could be for as they don't specify a line number.
any ideas?

Like you mentioned, you should load your application using index-debug.html while testing. Furthermore you can use Safari's developer tools to break on errors by clicking on the stop sign shaped "pause" button at the bottom of the Javascript debugger. This is helpful if the error message shows up inside of an Objective-J main file and you need to look at the full stack trace to figure it out.

i didn't realise the index-debug.html which will give me better errors.

Related

Why is my debugger "breaking" on a line where I have not set a breakpoint?

I apologize in advance, this will be a very basic & general beginner's question:
Why is my debugger "breaking" on a line where I have not set a breakpoint?
Some more detail:
I'm working on a large buggy C++ project in XCode 12.4.
I've set a single breakpoint on function A. The debugger refuses to break on function A. Instead, it breaks consistently on function B. Function A and B exist on the same cpp file. I believe function B is supposed to be called AFTER function A, but they definitely do not call each other and are not called simultaneously.
I've definitely experienced the debugger stopping on various errors, but with a RED highlight, not a GREEN one - as I understand it the GREEN highlight only happens on a breakpoint I set myself.
Is this expected behavior? Am I missing something obvious?
(First post, please tell me if I'm doing anything wrong!)
EDIT: I solved & answered my own question below!
The most common cause of the debugger pausing at a place where you didn't set a breakpoint is the throwing of an exception. Some exceptions crash the program, which is where you get the red highlight in the debugger. Some exceptions don't crash the program. In those cases the debugger highlights the exception breakpoint in green.
If the debugger pauses your program with a green highlight, click the Continue Execution button (it's the second button from the left in the group of debugging buttons right below the source code editor) or choose Debug > Continue in Xcode to continue running the program.
These are all great responses and I learned a lot from them all - but it turns out the answer was much dumber.
For whatever reason, when I compiled, XCode did not delete the previously compiled binary. As for my breakpoint issue, I'm still not 100% sure what was happening, but it is solved now.
Here's how I noticed: Function A did not exist when I compiled it last time. I had created a String in function A. This string assignment returned a bad access error - so I assume it was assigned outside the program I was debugging!
Thank you to responders!

How to debug when get error from D3

All:
I wonder if anyone could give me some clue that how to track the bug in D3.
For example, I draw a linechart, and I got some error from D3:
Error: Invalid value for <line> attribute y2="NaN" d3.js:7571
And this error is most possibly caused by some illegal(no value or NaN or etc) data binding in my code, but how can I trace back to locate where this error happen in my code rather in D3?
Thanks
I find that using the console in the Google Chrome browser is useful.
This can be enabled by pressing F12 when on the offending page and a separate window will open at the bottom.
The console tab on this window will present with information on errors found in the page.
As an example I inserted a 'random' semicolon in my d3.js code here;
(this is in the 'Geany' editor)
And in the console tab the error is identified as follows;
This shows you a description of the error and an indication of the area. In this case the console errored on the following line because it regards the semi-colon as valid, but that makes the following code invalid, but you get the idea.
In Firefox there is a plug-in called firebug I believe that will allow the same thing.
From my experience, there's isn't a really good way to debug this kind of error, but there's a workaround.
The error is thrown when an attribute value is set to NaN. Actually, that by itself would be easy to debug, because you could expand the error in the console and look through the stack trace to find in which file and on which line within call the stack the NaN value is set.
But that becomes impossible when you also have a transition. That's because the attr() call that's ultimately responsible for setting a NaN value runs asynchronously (i.e. via setTimeout at a later time). So you no longer get a stack trace that lets you see where in your code the NaN came from.
So, as a workaround, you can temporarily comment out all the transitions in your code, reload the page and you'll get an error that'll point you towards the line with the bug.
If you don't want to do that, then the only other option you have is to look at your code. You can narrow things down to the places in the code where you set attributes on a <line> node (since the error is about a <line>). Then you can insert a debugger statement in that general area and step through your code to find what causes your it to output NaN.

How to dynamically create a breakpoint on an expression in chrome?

Say I have some code in production. I want to test that a particular item in a large list of items has some behavior. One way to accomplish this in development with the debugger statement is like this:
items.forEach(function(item){
// some code...
if (item.title.match(/foo/)) {
debugger;
}
// some more code...
});
With that code, you put a breakpoint in a list, only when the list item matches some expression. This makes it easy to debug only that one item, which may have some obscure bug in it. If you just try to put a breakpoint there by clicking the line, then it's going to pause at every item in the list, so you have to step through like 100 items before you get there which is super tedious.
One problem with the above is, it requires you to have the ability to edit the client-side JavaScript, which you can't really do in production.
So the question is, can you accomplish this same sort of thing, but purely using the Chrome Web Inspector? Maybe something to do with "watch expressions" (haven't found much on google about those). The ideal would be, from within the Chrome Web Inspector, add an expression like:
breakpoint:
line: 17
file: build.js
expression: item.title.match(/foo/)
The closest you will get to this without getting into Chrome's chrome.debugger APIs are conditional breakpoints.
If you truly want to do this programmatically, look into chrome.debugger.sendCommand with the Debugger.setBreakpoint command.

How to use Visual Studio's Error List

Am I the only one who finds the error list in Visual Studio a little awkward to use? Can anyone explain why it behaves the way it does? When clicking on the Warnings tab or the Errors tab or the Messages tab you don't always get the errors, warning or messages. Insead, the view remains as it was already.
This may be an observation you already made but the Error, Warning and Info "buttons" in the error view are TOGGLE BUTTONS and show/hide the respective class of output message, which when I first came across them was not what I expected and did seem rather confusing.
Now I know they toggle the display of the correspondingly captioned output type on/off I find it quite sensible. It also behaves as expected; when you know what to expect!
It only make sense once you learned how it works. But, still this UI could confuse a lot of people when they have seen it the first time.
The Error/Warning/Message buttons look like Tabs but work like Checkboxes. It can be very confusing if a first time user clicks on them and execpts the behavior of Tab buttons.

CGContextSetCompositeOperation error for some users when drawing NSWindow

A simple 10.6 Cocoa app I wrote that basically draws a regular window with some buttons and text has been spewing hundreds of console log messages:
<Error>: CGContextSetCompositeOperation: invalid context 0x0
I do not directly call drawRect: and always use setNeedsDisplay:YES when I need to refresh.
Interestingly, this error does not happen on all machines, I'd say about 50% get the error. However, the program works fine in either case!
Anyone got any clue as to what this error means, where it's stemming from, and more importantly, how can I suppress/get rid of it?
Thanks
Try setting a breakpoint on CGPostError. If you can break on the logging, you can hopefully figure out what's going on.
You shouldn't be looking to just suppress it. It means context creation is failing (thus NULL gets passed for some context parameter), and that's not good.

Resources