The operation couldn’t be completed. (SQLite.Result error 0.) - sqlite.swift

I am running into sporadic issues in production with SQLite.Swift where calls return the following SQLite.Result: "The operation couldn’t be completed. (SQLite.Result error 0.)".
A quick web search shows that others have been encountering that specific error as well.
Looking at the source of Result: https://github.com/stephencelis/SQLite.swift/blob/master/Sources/SQLite/Core/Result.swift
How is it possible that such an error gets thrown?
The initializer returns nil if the errorCode is 0 (aka SQLITE_OK). What am I missing there?

Related

Castalia running error of type cRuntimeError

my omnetpp.ini has sim-time-limit = 1000s and runs normally until I get the error:
Running Castalia: Configuration 1/1 Run 1/1 Complete 0%terminate called after throwing an instance of 'cRuntimeError'
what(): Object Data is currently in (cMessageHeap)simulation.scheduled-events, it cannot be deleted. If this error occurs inside cMessageHeap, it needs to be changed to call drop() before it can delete that object. If this error occurs inside cMessageHeap's destructor and Data is a class member, cMessageHeap needs to call drop() in the destructor
When checking the trace, it recorded all the information correctly until 673.xxxx, in another execution, it stopped at 164.xxxx and in another at 978.xxxx.
Have you seen this error before? Could you point me to a possible solution.

What’s the meaning of “General variable binding error” in SNMP4J?

I use gettable to query some data successfully in one machine,but when I use the same command to query the other machine,it returns “General variable binding error”.How to fix it ? I can query the data in command line using Net-SNMP in the other machine.
That error message is defined in SnmpConstants.java as part of SNMP_ERROR_MESSAGES,
https://github.com/kaazing/snmp4j/blob/60518cb185e7738f94a9c754e85fa220afeffe6d/src/org/snmp4j/mp/SnmpConstants.java
You can see the error message is being used only in PDU.java,
https://github.com/kaazing/snmp4j/blob/60518cb185e7738f94a9c754e85fa220afeffe6d/src/org/snmp4j/PDU.java
and is only used when the SNMP response message has an error status of 5, aka GenErr.
That's unfortunately an ambiguous error reported by SNMP agents when they hit an exception that cannot be categorized to other error status.
So in your case,
try to use SNMP v2 to perform the queries and it usually gives a better error status code (v2 introduced more codes).
accept the fact that GenErr can happen and handle it (or ignore it).
Since it is an agent side behavior to return GenErr, you have no other option on the manager side.

Googleplay purchases.products.acknowledge return 400 not a valid state and 409 cocurrentUpdate

We try to do acknowledge google play purchase on the server-side through purchases.products.acknowledge with golang
However, the following errors come up sometime
googleapi: Error 409: The operation could not be performed since the object was
already in the process of being updated., concurrentUpdate
googleapi: Error 400: The purchase is not in a valid state to perform the desired operation
Is there anything am I missing? or how to solve those errors?
Per google support
For error 400, the purchaseState must be Purchased or 0 before you can acknowledge the purchase. For more information, please refer to this page: https://developer.android.com/google/play/billing/integrate#process
Error 400 can also mean that you already acknowledged the purchase.
For error 409, this means you are acknowledging the purchase multiple times concurrently. Unfortunately, we don't provide support for API concurrency issues.
Currently having this exactly issue, did you manage to resolve it in the end.
Acknowledgement Request Response: {
error: {
code: 409,
message: 'The operation could not be performed since the object was already in the process of being updated.',
errors: [ [Object] ]
}
}
I'm only sending it once, after i have validated and added to my database. I'm not sure why its happening.
EDIT:
I had a theory my code was executing to fast and maybe the order was still pending, so i added a 10 second gap between getting purchase token and then trying to acknowledge once again. Im now getting the following.
Acknowledgement Request Response: {
error: {
code: 400,
message: 'The purchase is not in a valid state to perform the desired operation.',
errors: [ [Object] ]
}
}
However at this time in Google Play Console, the state is Chargeable, meaning it just needs to be acknowledged.

Understanding ON ERROR in VBScript

I am trying to modify a vbscript and convert it to Powershell as instructed. I have a block of code on my function SearchAD with On Error.
on error resume next
Set objRS = command.execute
SearchAD = objRS.RecordCount
on error goto 0
My question would be is what part of the code can trigger RESUME Next and what part is for GOTO 0.
In VBScript there are two error states (three in other VBs).
On Error Goto 0
vbscript handles errors. Your program crashes on errors.
On Error Resume Next
VBScript sets the err object but doesn't raise an error. You are required to put after every line that may raise an error
If err.number <> 0 then
FreakoutAndFixTheError
err.clear
wscript.quit 'if you can't fix
End If
In VB6 and VBA there is also
On Error Goto LineNumber (or a label)
Simply put, On Error Resume Next disables error reporting. And On Error GoTo 0 restores it. It's often used when a programmer expects an error to occur but doesn't want that error to go unhandled and halt their script. For example:
' This statement will cause VBScript to throw an error and halt.
i = 1 / 0
' Instead, let us handle the error and decide if its important...
On Error Resume Next ' Turn off error reporting
i = 1 / 0
' Now, we can test the Err object to see if any errors were thrown...
If Err.Number = 0 Then
' Success. No error occurred.
ElseIf Err.Number = 11 Then
' Error #11 is 'Division by zero'. Do we want to allow it?
End If
' We're through the risky section. Restore error reporting.
On Error GoTo 0
Now time for a soap box rant. Don't use it. There are almost always better ways than using On Error Resume Next. Assert variable values. Check your array bounds before trying to access array elements. Do QA testing. Validate user input. Be a good programmer and cover all your angles. Don't just close your eyes to any errors and assume everything is going to work. It's abused all too often by VB beginners and, unfortunately, even some of the experts! (end rant)
Here is the VB6 (more depth than vbscript's) help on it. VBA is the core language of VB6.
Visual Basic for Applications Reference
On Error Statement
Enables an error-handling routine and specifies the location of the routine within a procedure; can also be used to disable an error-handling routine.
Syntax
On Error GoTo line
On Error Resume Next
On Error GoTo 0
The On Error statement syntax can have any of the following forms:
Statement Description
On Error GoTo line
Enables the error-handling routine that starts at line specified in the required line argument. The line argument is any line label or line number. If a run-time error occurs, control branches to line, making the error handler active. The specified line must be in the same procedure as the On Error statement; otherwise, a compile-time error occurs.
On Error Resume Next
Specifies that when a run-time error occurs, control goes to the statement immediately following the statement where the error occurred where execution continues. Use this form rather than On Error GoTo when accessing objects.
On Error GoTo 0
Disables any enabled error handler in the current procedure.
Remarks
If you don't use an On Error statement, any run-time error that occurs is fatal; that is, an error message is displayed and execution stops.
An "enabled" error handler is one that is turned on by an On Error statement; an "active" error handler is an enabled handler that is in the process of handling an error. If an error occurs while an error handler is active (between the occurrence of the error and a Resume, Exit Sub, Exit Function, or Exit Property statement), the current procedure's error handler can't handle the error. Control returns to the calling procedure. If the calling procedure has an enabled error handler, it is activated to handle the error. If the calling procedure's error handler is also active, control passes back through previous calling procedures until an enabled, but inactive, error handler is found. If no inactive, enabled error handler is found, the error is fatal at the point at which it actually occurred. Each time the error handler passes control back to a calling procedure, that procedure becomes the current procedure. Once an error is handled by an error handler in any procedure, execution resumes in the current procedure at the point designated by the Resume statement.
Note An error-handling routine is not a Sub procedure or Function procedure. It is a section of code marked by a line label or line number.
Error-handling routines rely on the value in the Number property of the Err object to determine the cause of the error. The error-handling routine should test or save relevant property values in the Err object before any other error can occur or before a procedure that might cause an error is called. The property values in the Err object reflect only the most recent error. The error message associated with Err.Number is contained in Err.Description.
On Error Resume Next causes execution to continue with the statement immediately following the statement that caused the run-time error, or with the statement immediately following the most recent call out of the procedure containing the On Error Resume Next statement. This statement allows execution to continue despite a run-time error. You can place the error-handling routine where the error would occur, rather than transferring control to another location within the procedure. An On Error Resume Next statement becomes inactive when another procedure is called, so you should execute an On Error Resume Next statement in each called routine if you want inline error handling within that routine.
Note The On Error Resume Next construct may be preferable to On Error GoTo when handling errors generated during access to other objects. Checking Err after each interaction with an object removes ambiguity about which object was accessed by the code. You can be sure which object placed the error code in Err.Number, as well as which object originally generated the error (the object specified in Err.Source).
On Error GoTo 0 disables error handling in the current procedure. It doesn't specify line 0 as the start of the error-handling code, even if the procedure contains a line numbered 0. Without an On Error GoTo 0 statement, an error handler is automatically disabled when a procedure is exited.
To prevent error-handling code from running when no error has occurred, place an Exit Sub, Exit Function, or Exit Property statement immediately before the error-handling routine, as in the following fragment:
Sub InitializeMatrix(Var1, Var2, Var3, Var4)
On Error GoTo ErrorHandler
. . .
Exit Sub
ErrorHandler:
. . .
Resume Next
End Sub
Here, the error-handling code follows the Exit Sub statement and precedes the End Sub statement to separate it from the procedure flow. Error-handling code can be placed anywhere in a procedure.
Untrapped errors in objects are returned to the controlling application when the object is running as an executable file. Within the development environment, untrapped errors are only returned to the controlling application if the proper options are set. See your host application's documentation for a description of which options should be set during debugging, how to set them, and whether the host can create classes.
If you create an object that accesses other objects, you should try to handle errors passed back from them unhandled. If you cannot handle such errors, map the error code in Err.Number to one of your own errors, and then pass them back to the caller of your object. You should specify your error by adding your error code to the vbObjectError constant. For example, if your error code is 1052, assign it as follows:
Err.Number = vbObjectError + 1052
Note System errors during calls to Windows dynamic-link libraries (DLL) do not raise exceptions and cannot be trapped with Visual Basic error trapping. When calling DLL functions, you should check each return value for success or failure (according to the API specifications), and in the event of a failure, check the value in the Err object's LastDLLError property.
Send feedback to MSDN.Look here for MSDN Online resources.

Retry on Runtime Errors

I have come across this problem a few times and never been able to resolve it but now I need to solve it once and for all.
I have a procedure which has been throwing runtime errors. This is not a problem as I have an error handler defined at the top of the function and the handler at the bottom something like this:
retryConcat:
On Local Error GoTo concatErr
'Some Code here
Exit Sub
concatErr:
If MsgBox("Could not append the receipt for this transaction to the Receipt viewer logs.", vbExclamation + vbRetryCancel, "Warning - Missing Receipt") = vbRetry Then
err.Clear
GoTo retryConcat
End If
The error handler contains a message box allowing the user to retry if required. Now here is the part which confuses me. The first time an error is thrown it shows the message box and allows the user to retry as expected. The program then jumps to the appropriate line and tries again. However the second time through when the error is thrown it does not jump to the error handler, it jumps out of the procedure and the error handler in the parent catches it instead!
So my question is why does it jump to the parent error handler on subsequent throws. This happens in many places all over my code. In many cases where I can manually check for errors I can stick the code in a while loop to solve it but with runtime errors I am forced to use the error trapping which acts in this rather annoying way.
Any help or advice would be appreciated.
You need ot use Resume retryConcat.
When an error occurs, it jumps into the error handle to concatErr:. You then show the message box, and if the user chooses to retry, the code then jumps to retryConcat. As this you used Goto, it DOES NOT exit the error handler, and so next time the error occurs, it's already in the error handler and has no choice but to raise the error up the chain to the calling procedure.
Using Resume concatRetry allows it to exit the error handler and resume at the required point, meaning next time the error occurs, it can handle is again.
It probably makes it easier to understand, if you imagine the error handler is a state, not a section of code.

Resources