Errors in my code - class

Alright, I have a couple error messages and I am stuck. Just seeing if anybody could help me out here, it would be greatly appreciated.
Here is the error message:
bibleajax.cpp: In function Ă¢int main():
bibleajax.cpp:92: error: no matching function for call to Bible::lookup(Verse&, LookupResult&)
Bible.h:32: note: candidates are: const Verse Bible::lookup(Ref, LookupResult&)
make: * [bibleajax.o] Error 1
Here is line 92:
Ref nRef;
Verse nVerse;
for (int t = 0; t < num; t++){
do {
nRef = kjv.lookup(nVerse, result);
nVerse = kjv.lookup(nRef, result);
}
while (result != ch && result != no_chapter);

It would appear that your Verse class does not have a member function called getRef(). You also appear to be trying to call the lookup function by passing it a Verse object instead of a Ref object... but that piece of code doesn't seem to be included in what you've posted here.
Note that the relevant line numbers for the code are posted in the error messages. So check lines 79 and 92 for the issues I mentioned here.

Related

How do I print a message if a ValueError occurs?

while answers_right < 3:
ran_number_1 = random.randint(10, 99)
ran_number_2 = random.randint(10, 99)
solution = ran_number_1 + ran_number_2
print(f"What is {ran_number_1} + {ran_number_2}?")
user_answer = int(input("Your answer: "))
if user_answer == solution:
answers_right += 1
print(f"Correct. You've gotten {answers_right} correct in a row.")
elif user_answer != solution:
answers_right = 0
print(f"Incorrect. The expected answer is {solution}.")
if answers_right == 3:
print("Congratulations! You've mastered addition.")
I want to add an additional if statement in case someone types string and return a message that says "Invalid Response" instead of the Traceback Error.
Use of Exception handling in python may be solve your Problem and you can also generate your own error class for particular condition.
if x < 3:
raise Exception("Sorry, no numbers below 3")
Use of throw and raise keyword you can generate your own error.
for more referencelink here
The correct way to solve this problem is to look at the error type in your traceback, and use a try/except block. It will say something like TypeError: error stuff here or ValueError: error stuff also here.
The way you do a try/except is to:
try:
some_code()
that_might()
produce_an_error()
except some_error_type:
do_stuff()
except_some_other_error_type:
do_other_stuff()
So, to catch a ValueError and a TypeError, you might do:
try:
buggy_code()
except ValueError:
print("Woah, you did something you shouldn't have")
except TypeError:
print("Woah, you did something ELSE you shouldn't have")
If you then want the traceback, you can add in a lone "raise" statement below the excepts. For example:
try:
buggy_code()
except ValueError:
print("Woah, you did something you shouldn't have")
raise
except TypeError:
print("Woah, you did something ELSE you shouldn't have")
raise
Errors have evolved to be a lot more useful in modern times. They don't break the entire system anymore, and there are ways of handling them. Try/Except blocks like the above give you the tools to have code that only executes when a specific error or set of errors is raised.

[zetapush]Error in macro: code=SUB_ASSIGN - Message = Assignment failed

When calling a macro I have the following error in response:
code=SUB_ASSIGN
Message = Assignment failed
Location= Reduce at line 65 of file mymacro.zms
the line 65 is
/** Reduce */
var b = gda(GDA).reduce {
table: 'myTable',
start: __parameters.key + '##',
stop: __parameters.key + '##a',
page: {
pageNumber: 0,
pageSize: 100000000
},
initialValue: {
tR: tR,
count: 0
},
'columns': ['col1', 'col2'],
'function': usr:myfunc
};
Seen on Android SDK (not on JS SDK) and not 100% reproducible.
What's the meaning of this error and how can I correct it?
Thanks.
The (poorly documented) meaning of SUB_ASSIGN is that an assignment with a syntax like a.b.c = d; has failed.
More precisely, the left hand operand is made of several hierarchical sub-parts (in my example a, b, and c).
Note that SUB_ASSIGN reports a programming error, which you should guard against :
when assigning a.b.c, at least a.b must exist and be not null.
A code pattern such as this one should do the trick:
// the ?? operator returns true when an expression is defined and not null
if (! a.b ??) {
a.b = {};
}
...
a.b.c = 0;
or, shorter, if applicable :
if (! a.b ??) {
a.b = {c:0};
}
The relevant documentation for '??' can be found in the official API reference documentation
As your code does not include such a statement anyway, I suppose that the actual error does not lie in your reduce call, but inside your callback function (usr:myfunc).
Moreover, to ease further debugging :
the error report you gave does not seem to contain the full stack trace up to the callback of the 'reduce' call. This might very well be a missing/not-yet-implemented feature of the zetapush API (which you could request...).

iOS JavascriptCore exception detailed stacktrace info

It seems the exception stacktrace in iOS only contains the method name or there is a bug. Below is my code of handling exceptions in JSContext.
context.exceptionHandler = { (ctx: JSContext!, value: JSValue!) in
// type of String
let stacktrace = value.objectForKeyedSubscript("stack").toString()
// type of Number
let lineNumber = value.objectForKeyedSubscript("line")
// type of Number
let column = value.objectForKeyedSubscript("column")
let moreInfo = "in method \(stacktrace)Line number in file: \(lineNumber), column: \(column)"
Logger.error("JS ERROR: \(value) \(moreInfo)")
}
And I got logs like below
ERROR : JSContextRenderer.swift:308 : setupContext : JS ERROR: Error in method clearBackground
Line number in file: 162, column: 12"
Note there is a new line right after the "clearBackground" name, I think there probably more information there.
Can anybody having similar experience confirm? Any help is appreciated. Thanks.
Looks like it does show more information in the stack. Here is one of the log information I got:
JS ERROR: TypeError: undefined is not a function (evaluating 'msg.__assert__()') in method assert
syncShots
updateSync
initSync
setState
onLogicStateChanged
onLogicStateChanged
[native code]
updateMove
sendMove
shoot
onTouchUp
[native code]
_handleEvent
_dispatchEvent
. Line number in file: 183, column: 20
Long ago, #igrek asked where the keys in value come from. They're part of the Error object that was thrown by the JavaScript engine, and that now appears as value in the native error handler callback. What exactly Error includes depends on the implementation, but typically includes message, fileName, and lineNumber. It appears that stack is also supported. More details on the MDN page for Error .

Useless use of private variable in void context in simple perl loop, no idea where the error is

if ( $num_of_things > 1) {
my $max_element = $num_of_things -1;
for($max_element; $max_element >= 0; $max_element--) {
$value_array[$max_element] = $starting_hash{$key}[$max_element];
}
All of my variables not initialized in this code snippet have been initialized as part of the larger subroutine (which I don't want to put up due to length). I'm not sure where I'm getting the useless use of private variable in void context error in this code, my compiler is telling me it's the last line (with nothing but the closing brace "}"). All help is hugely appreciated as I've been staring at this loop for almost an hour with no idea what is wrong.
Move initialization (and declaration) of $max_element into for statement.
[see ooga comment ]
for( my $max_element=$num_of_things-1; $max_element>= 0; $max_element--) {
$value_array[$max_element] = $starting_hash{$key}[$max_element];
}

How to call a function of postgis-1.5.dll in c code

I'm creating an Postgresql extension in c that use Postgis Point. when i try to call a function of postgis-1.5.dll after loading it, it fails and i get no error message
Here is a small part of my code:
Point *pt =(Point*) palloc(sizeof(Point));
bool test;
HINSTANCE DLLHandle;
typedef bool(*ST_empty)(Point*);
ST_emptyPtr ST_empty;
pt->x = 0.2;
pt->y = 0.9;
DLLHandle = LoadLibrary(L"postgis-1.5.dll");
ST_empty = (ST_emptyPtr)GetProcAddress(DLLHandle,"LWGEOM_isempty");
if (DLLHandle != NULL){
if(!ST_empty)
elog(ERROR,"null ehhhh");
test = ST_empty(p);
elog(ERROR,"not empty");
}
Could anyone help me?
It may help to look at the source:
lwgeom_is_empty from PostGIS Trunk
Are you sure it's failing? The code above doesn't test the return value from the function call. What does the following do?
if (!ST_empty(p))
elog(ERROR,"not empty");
Brian