Getting this message app.js:33 Uncaught TypeError: Cannot read property 'appendChild' of null at HTMLButtonElement.addTodo - appendchild

enter image description here
enter image description here
I had to initially put the behind the body because it was refreshing the page.
Now i'm running into this error "app.js:33 Uncaught TypeError: Cannot read property 'appendChild' of null
at HTMLButtonElement.addTodo"

Your selector is .todo-List, yet all your other class names don't use any upper-case characters, and your HTML shows class="todo-list" (list, not List!) as well.
So, I'd assume that this is a typo and should actually be todo-list with lower-case l, so you should change the line 4 to const todoList = document.querySelector('.todo-list').
The fact that you asked about the "message" of Cannot read property "appendChild" of null though sounds to me as if you didn't understand the error message. Please take the time to review this article and take a quick squiz at how to use a debugger. Especially the latter is a tremendously important skill that will help you trace back those issues yourself. I'm sure, had you realized that the issues comes from line 4, you'd eventually have discovered that the selector is wrong.

Related

amp-bind Error: Default value for [variable] does not match first expression result

I am using amp-bind to bind the class attribute:
<div [class]="menu.menuClass" class=hide">...</div>
with the following amp-state element:
<amp-state id="menu">
<script type="application/json">
{"menuClass":"hide"}
</script>
</amp-state>
However, after the page loads, I get the error:
amp-bind: Default value for [class] does not match first expression result (hide). This can result in unexpected behavior after the next state change.​​​
(this error is empedded in the div itself)
As you can see, my default value does match the first expression. What am I doing wrong?
Ah, this is a bug! :) I've filed this issue and we're working on a fix.
We try to keep an eye on StackOverflow but feel free to file an issue in our GitHub project or ask a question on our Slack channel next time. Thanks for raising this, Gil.

How to get Developer Exception page to show multiple lines of code around exception?

This page https://learn.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.builder.developerexceptionpageoptions states that a DeveloperExceptionPageOptions object can be passed as a parameter to app.UseDeveloperExceptionPage() and one of the properties on the options object is SourceCodeLineCount. Specifically, it says that the SourceCodeLineCount property:
Determines how many lines of code to include before and after the line of code present in an exception's stack frame. Only applies when symbols are available and source code referenced by the exception stack trace is present on the server.
But when I put the following code in the Configure method of the startup.cs class:
app.UseDeveloperExceptionPage( new DeveloperExceptionPageOptions() { SourceCodeLineCount = 10} );
The output in the Developer Exception Page doesn't appear to show the 20 lines of source code that it's suppose to.
How does one get the Developer Exception page to show multiple lines of code around exception?
I'm not sure if you're still having this problem or not, but have you tried browsers other than IE? When I'm running in Chrome, I'm seeing a little [+] symbol on the left of each line number, that can be used to expand each snippet of code.
The line that the error occurs is highlighted in red, and the SourceCodeLineCount value (in my case, set to 2) is used to display the number of lines above the line that caused your exception.
See sample screenshot below. Hope this helps!

Type mismatch error while reading lotus notes document in vb6

Am trying to read the lotus notes document using VB6.I can able to read the values of the but suddenly type mismatch error is throwed.When i reintialise the vb6 variable it works but stops after certain point.
ex; address field in lotus notes
lsaddress=ImsField(doc.address)
private function ImsField(pValue)
ImsField=pValue(0)
end function
Like this I am reading the remaining fields but at certain point the runtime error "13" type mismatch error throwed.
I have to manually reintialize by
set doc=view.getdocumentbykey(doclist)
The type mismatch error occurs for a certain field. The issue should be a data type incompatibility. Try to figure out which field causes the error.
Use GetItemValue() instead of short notation for accessing fields and don't use ImsField():
lsaddress=doc.GetItemValue("address")(0)
The type mismatch is occurring because you are encountering a case where pValue is not an array. That will occur when you attempt to reference a NotesItem that does not exist. I.e., doc.MissingItem.
You should not use the shorthand notation doc.itemName. It is convenient, but it leads to sloppy coding. You should use getItemValue as everyone else is suggesting, and also you should check to see if the NotesItem exists. I.e.,
if doc.hasItem("myItem") then
lsaddress=doc.getItemValue("myItem")(0)
end if
Notes and Domino are schema-less. There are no data integrity checks other than what you write yourself. You may think that the item always has to be there, but the truth is that there is nothing that will ever guarantee that, so it is always up to you to write your code so that it doesn't assume anything.
BTW: There are other checks that you might want to perform besides just whether or not the field exists. You might want to check the field's type as well, but to do that requires going one more level up the object chain and using getFirstItem instead of getItemValue, which I'm not going to get into here. And the reason, once again, is that Notes and Domino are schema-less. You might think that a given item must always be a text list, but all it takes is someone writing sloppy code in an one-time fix-it agent and you could end up having a document in which that item is numeric!
Checking your fields is actually a good reason (sometimes) to encapsulate your field access in a function, much like the way you have attempted to do. The reason I added "sometimes" above is that your code's behavior for a missing field isn't necessarily always going to be the same, but for cases where you just want to return a default value when the field doesn't exist you can use something like this:
lsaddress ImsField("address","")
private function ImsField(fieldName,defaultValue)
if doc.hasItem(fieldName) then
lsaddress=doc.getItemValue(fieldName)(0)
else
lsaddress=defaultValue
end if
end function
Type mismatch comes,
When you try to set values from one kind of datatype variable to different datatype of another variable.
Eg:-
dim x as String
Dim z as variant
z= Split("Test:XXX",":")
x=z
The above will through the error what you mentioned.
So check the below code...
lsaddress = ImsField(doc.address)
What is the datatype of lsaddress?
What is the return type of ImsField(doc.address)?
If the above function parameter is a string, then you should pass the parameter like (doc.address(0))

How does a DataObjects::SQLError object's .code correspond to the error issued by the database?

So I'm doing some business logic and want to run some code that goes like
select id from blah where foo = 1234 for update nolock
This code throws a DataMapper::SQLError when the corresponding row in blah is locked. This is desirable behavior; I would like to catch this error and use it to inform my application logic. But I want to re-throw any other SQL errors, because they're different than the case I'm programming for, and catching them in the same way would be wrong.
The error object returned has a string error message, and a numeric code (50463045). It seems like comparing on the numeric code would be great, but I don't want to embed the constant 50463045 in my code without some modicum of understanding of how the heck it was determined. Notably, the Postgres manual suggests that the error code for this state is 55P03, and that doesn't seem to be the same thing. I don't have any idea how much I can trust this magic number, and how to determine it except for experimentally, so I'm not really comfortable with using it.
How is the error code determined?
The Internet was distressingly unhelpful, since searching for stuff about DataObjects SQL errors seems to mostly return problems with other software raising the errors, not information on the errors themselves... but after locating the right source code and browsing around through the source code I finally located do_postgres.c:
void do_postgres_raise_error(VALUE self, PGresult *result, VALUE query) {
const char *message = PQresultErrorMessage(result);
char *sql_state = PQresultErrorField(result, PG_DIAG_SQLSTATE);
int postgres_errno = MAKE_SQLSTATE(sql_state[0], sql_state[1], sql_state[2], sql_state[3], sql_state[4]);
PQclear(result);
data_objects_raise_error(self, do_postgres_errors, postgres_errno, message, query, rb_str_new2(sql_state));
}
Notice how a 5-character state is passed to MAKE_SQLSTATE... and then also passed to data_objects_raise_error itself. I couldn't track down where MAKE_SQLSTATE is defined to figure out what crazy manipulations are going on to make this integer, but it appears I can just use the error object's .sqlstate property directly, and make my condition e.sqlstate == '55P03'.

Cannot access animate-properties in Clutter

I am trying to animate an actor in Clutter, but when I enter a property that exists, something goes wrong.
actor.animate( AnimationMode.LINEAR, 400, scale_x:2);
gives me this error
Clutter-WARNING **: Cannot bind property '\x83\xec\u0014\x89\xc6e\xa1\u000c': objects of type 'ClutterTexture' do not have this property
Looks like Unicode-characters to me.
However, when I enter a property that does NOT exist
actor.animate( AnimationMode.LINEAR, 400, thisdoesntwork:2);
I get an error that makes much more sense
Clutter-WARNING **: Cannot bind property 'thisdoesntwork': objects of type 'ClutterTexture' do not have this property
I get the exact same problem when I try this alternative approach:
actor.animate( AnimationMode.LINEAR, 400, "scale-x", 2);
How come all properties that actually exist get converted to some mess, and what can I do to get this to work?
You should be using 2.0 for the value, not 2. 2 is an integer, 2.0 is a double. Vala can't provide type safety for variadic methods, so you have to be careful.
As for why you're seeing the behavior you are for properties which exist, my guess is it has to do with the fact that 2 is a (32-bit) integer and 2.0 is a (64-bit) double. This is simplifying things a bit, and I don't know how much experience you have with C (probably not a lot, since this is the sort of mistake someone coming from a dynamically typed language would make), however... Clutter (well, va_arg) expects a double so it parses 64 bits of data, but you only provided 32 bits, so the first 32-bits of the next argument (NULL) are included. Now, when it starts trying to parse the next argument it starts from the wrong location (32-bits into the argument), so you get the the remainder of NULL and part of whatever garbage happened to be on the stack... Unsuprisingly, that doesn't just so happen to be 32-bits of 0s so when Clutter tests to see if the value it just read == NULL it isn't and Clutter thinks it's been given a pointer to an null-terminated array of characters (which is how strings are represented in C). It reads the data at that location, which just so happens to be \x83\xec\u0014\x89\xc6e\xa1\u000c, and checks to see if there is a property with that name. There isn't, so it emits the error message you saw.
Now, if you switch to using a property which doesn't exist, Clutter will parse the argument (the name of the property), notice that it doesn't exist (just like it did with the second property above), and emit an error.

Resources