Cannot use transfer or send on solidity - ethereum

I use Ganache, truffle.
I get the following error:
Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction
I have located the problematic piece of code:
bool sent = _sellerAddress.send(_price);
Now, I get the price via the user interaction, and when the price is 0, then the error is not thrown,
unfortunately in the classic case when the _price is no zero, the exception is thrown.
Any suggestions?

Related

SharpSnmpLib SNMP read exception using library SharpSnmpLib

I get exception when doing snmp get.
Here is the Wireshark dump of the packet that gives the exception:
Lextm.SharpSnmpLib.SnmpException: data construction exception --->
System.ArgumentException: Truncation error for 32-bit integer coding.
Parameter name: length
I found the problem I was sending too big requestID or negative requestID which are not supported by some devices!
Use this option to disable negative request ID
Messenger.UseFullRange = false;

JUnit4 - format assert message _after_ failure detected

Supposing I have non-trivial calculation function taking a bunch of parameters. And I have to test it for at least thousands of cases.
And I would like to have detailed message with all parameters values specified when certain case fails. I can format message string before check and pass it to assertXXX method. But it is very ineffective. My test spends most of its time formatting strings.
My question is:
Is there any smart way to format message string and pass it to JUnit after a test failure is detected and only then?
if (foo.conditionThatCanFail()) {
fail("condition failed for "+ foo);
}
As #bmargulies suggested, some assertion frameworks l(ike Hamcrest, Fest or Truth) will provide a nicely formatted failure message if an assertion fails.

Prevent checkElementIndex() Guava function from concatenating additional response to existing error message

Preconditions.checkElementIndex(startIndex, personMemberGroupMap.keySet().size(), "Error: Offset exceeds the total number of records that can be displayed");
The above code checks if the given index is present in the personMemberGroup map. If it isn't then I throw a error message. This error message is then added to the IndexOutOfBounds exception that is thrown.
I have a test case in jUnit to test the above statement. In this test case I check the error message that is passed with the exception.
assertEquals("Error: Offset exceeds the total number of records that can be displayed", e.getMessage());
But the assertion turns out to be false and the actual message in the exception states
"Error: Offset exceeds the total number of records that can be displayed (3) must be less than size (3)"
The string displayed (3) must be less than size (3) was appended by the badElementIndex() method within the Preconditions class.
How do I evaluate my error message. Is there a way of preventing it from appending the extra message or am I providing the error message in the wrong format?
Preconditions.checkElementIndex() always formats the message of the exception.
You can see for yourself the call to badElementIndex() on line 305.

Fetching Error Code in mule

I want to create a custom exception message in case exception is thrown by my mule service. In order to do that, i want to separately capture mule generated ErrorCode. Is there any property using which i can get that value? I tried using #[org.mule.config.ExceptionHelper.getErrorCode(Exception.class)]" but this returned -1 as a value instead of the actual exception code.
What method can i use to fetch ErrorCode?
You are supposed to pass the class of the current exception, ie:
#[org.mule.config.ExceptionHelper.getErrorCode(exception.class)]"
exception is the current exception while Exception is the java.lang.Exception class for which there is no error code associated.

BeepBeep and ErlyDB integration issue

Further to my adventures with Erlang and ErlyDB. I am attempting to get ErlyDB working with BeepBeep
My ErlyDB setup works correctly when run outside of the BeepBeep environment (see Debugging ErlyDB and MySQL). I have basically take the working code and attempted to get it running inside BeepBeep.
I have the following code in my controller:
handle_request("index",[]) ->
erlydb:start(mysql,Database),
erlydb:code_gen(["thing.erl"],mysql),
NewThing = thing:new_with([{name, "name"},{value, "value"}]),
thing:save(NewThing),
{render,"home/index.html",[{data,"Hello World!"}]};
When I call the URL, the response outputs "Server Error".
There is no other error or exception information reported.
I have tried wrapping the call in try/catch to see if there is an underlying error - there is definitely an exception at the call to thing:new_with(), but no further information is available.
The stacktrace reports:
{thing,new,[["name","value"]]}
{home_controller,create,1}
{home_controller,handle_request,3}
{beepbeep,process_request,4}
{test_web,loop,1}
{mochiweb_http,headers,4}
{proc_lib,init_p_do_apply,3}
Use pattern matching to assert that things work up to the call to thing:new/1:
ok = erlydb:start(mysql,Database),
ok = erlydb:code_gen(["thing.erl"],mysql),
You include only the stack trace, look at the exception message as well. I suspect that the error is that you get an 'undef' exception. But check that it is so. The first line in the stack trace indicates that it is a problem with calling thing:new/1 with ["name", "value"] as argument.
It is slightly odd that you show one clause of handle_request that is not calling home_controller:create/1 as per {home_controller,create,1} in the stack-trace. What do the other clauses in your handle_request/2 function look like?