Questions tagged [exceptions]

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.

Filter by
Sorted by
Tagged with
1
vote
2answers
25 views

Does any reverting instruction (assert, require, revert, throw, etc) undo ETH transfer?

I have code which transfer the ether to another address. And below that, I have require() condition will be failing. so will that execute the ether transfer or it will not transfer? function ...
0
votes
1answer
51 views

Testing a function in Solidity

and am trying to write some test for a payable function in Solidity but i don't know how to go about it any help will be appreciated . I want to test for the case where the buyer send an amount less ...
1
vote
1answer
194 views

Assert and require response error message

I have one sentence in my code that is evaluating a condition. If the evaluation fail´s I throw a execption with assert and require. In my case I think that require is the indicated election for a ...
0
votes
1answer
154 views

Is it safe to call revert() instead of returning a value?

I have the following piece of code: function func() public returns (bool) { if (some condition on msg.sender) { do some stuff return true; } revert(); } The compiler (0.4....
1
vote
3answers
207 views

Test array values if key/value exists - Does not work

I have a problem with the following contract. When I deploy it, normally on calling the function addBalance() it should go into the false. But instead, it completely does not work and I get the ...
1
vote
2answers
141 views

What should happen if I push a value into array and the function fail afterwards?

What should happen when I modify an array, afterwards in the same execution the function fails? Should I expect the pushed value to be presented or does it get deleted? for example: contract ...
0
votes
1answer
24 views

Why assert expends gas while require does not? (My intuition says te opposite is true)

Since assert corresponds to conditions that must never happen if the smart-contract code is correct my intuition tells me that someone calling an smart-contract that raises an assert must never be "...
3
votes
1answer
139 views

Call a zero-initialized variable of internal function type

I was reading solidity documentation about when an assert-style exception is generated. In the 6th point it says: "If you call a zero-initialized variable of internal function type." I don't ...
0
votes
2answers
47 views

How to see Logs of exceptions?

I'm using solidity compiler ^0.4.23, I added logs to the function at exception points like this: function firstSaleDelivery(address _beneficiary, uint256 rate) public onlyOwner{ require(!...
0
votes
1answer
157 views

Do Truffle methods automatically raise time-out exceptions?

Do the Solidity library functions automatically raise exceptions if a time-out error occurs? For example, what happens if the sendCoin() method call in this Truffle doc page times out (never completes)...
1
vote
0answers
572 views

Metamask-Rinkeby Transaction Error. Exception thrown in contract code in Rinkeby?

Can anyone explain why I'm get error every time for 'buyFor' function from my contracts? pragma solidity ^0.4.11; import "./ownable.sol"; contract GLOERC20Coin is Ownable{ string public name; ...
0
votes
0answers
300 views

Consequences of 'VM Exception while processing transaction: invalid opcode'

The question Hello everyone, could anyone explain to me the consequences of: VM Exception while processing transaction: invalid opcode. The context I'm passing in an integer in web3js that is not ...
0
votes
1answer
27 views

What is an example of a require-style exception when receiving ether via a public getter?

In the Solidity documentation it is stated that: A require-style exception is generated in the following situations: ... If your contract receives Ether via a public getter function. ...
2
votes
2answers
146 views

Does ether transfer consume all gas in case of exception?

If addr.transfer() fails, does it use a revert- or throw-style exception? In other words, does a failed transfer consume all provided gas?
0
votes
1answer
428 views

Transaction receipt is 0x1 but the execution failed. How is it possible

https://etherscan.io/tx/0x20081e3012905d97961c2f1a18e1f3fe39f72a46b24e078df2fe446051366dca As you can see from web3.eth.getTransactionReceipt { blockHash: '...
0
votes
1answer
400 views

Open Zeppelin crowdsale requires too much gas

EDIT: we spotted the mistake in the code, endtime = starttime I deployed with truffle a subclass of zeppelin popular crowdsale contract GorillaSale is Crowdsale { function GorillaSale( uint256 ...
0
votes
1answer
216 views

Opcode for out of gas inside a message call

According to the Solidity documentation: A require-style exception is generated in the following situations: ... If you call a function via a message call but it does not finish properly (i.e. ...
0
votes
1answer
56 views

Mist crashing on startup UNCAUGHT EXCEPTION TypeError

I'm running the Ethereum wallet Mist in Ubuntu but it crashes on start up with this message [2017-10-01 13:45:59.552] [INFO] EthereumNode - Start node using /home/oscar/.config/Mist/binaries/Geth/...
7
votes
1answer
858 views

How to map EVM trace to contract source?

In other words, how to get "classic stacktrace" of failed transaction? E.g. we have a trace (don't look at "Missing opcode 0xfd" - its the revert instruction) and the contract solidity source. How ...
1
vote
1answer
162 views

Bad Jump Destination, how can i tell programmatically?

Let's say i'm programmatically making a transaction to a contract. How can I tell (programmatically) that the confirmed transaction has a Bad Jump Destination? Right now, the only way I know of is ...
1
vote
1answer
45 views

How to see that a constant method threw an exception?

Consider this contract pragma solidity ^0.4.11; contract GoodAndBad { function exec(uint flag) public constant returns (uint) { assert(flag == 1); return 0; } } How do I know that ...
4
votes
1answer
63 views

Is the Ethereum Subtleties page correct about value transfers under exceptions?

On the Ethereum Subtleties page (largely maintained by VB) it states the following under Exceptional Conditions: If a transaction triggers an exception, then: The value transfer from ...
11
votes
3answers
5k views

Why do `throw` and `revert()` create different bytecodes?

throw and revert() are both compiling to the revert operation (opcode 0xfd). According to the docs: The throw keyword can also be used as an alternative to revert(). Why is it then that the ...
1
vote
1answer
557 views

Why does Solidity use an invalid jump instead of an invalid opcode for throws?

In Solidity's 0.4.9 release: Internal exceptions are now thrown by using an invalid opcode (0xfe), manual exceptions still use an invalid jump. and Code generator: Internal errors (array out ...
1
vote
2answers
2k views

Solidity: Is there any catch mechanism for throw? If not switch into return usage might be better?

Based on experienced mentors it seems like throw mechanism is suggested here. I guess catch mechanism does not exist for throw: https://ethereum.stackexchange.com/a/2512/4575. Based on that I have a ...
66
votes
3answers
22k views

Difference between require and assert and the difference between revert and throw

I was looking at the docs and Im looking for clarification on the difference between require and assert and throw and revert. assert(bool condition): abort execution and revert state changes if ...
5
votes
3answers
972 views

Would it be better to use `throw` instead of `return false`?

My goal is to carry out some simple function but the user should be aware if the call fails. An example simple function could be seen here. Instead of return false, I want to use throw. Would their ...
4
votes
2answers
476 views

Contract created by another contract and exceptions

I have two questions regarding contract creation and exceptions: If contract A creates contract B and then throws in the same function, is B also deleted? If contract A creates contract B, and B ...
4
votes
2answers
125 views

Is there an advantage rollbacking the transactions with 'throw' over returning an error code?

Most of the code I read out in the wild follow the precondition pattern if (condition) throw; But this approach is cumbersome for clients to read. For example, with web3js you would have to check if ...
4
votes
0answers
101 views

Did the ripemd precompiled contract get deleted?

A bug "caused account 0000000000000000000000000000000000000003 to be deleted in block 2675119, even though the deletion should have been reverted due to an out of gas error." Source Did account 0..3 ...
3
votes
0answers
73 views

How did the “state clearing” transactions run Out of Gas?

"Failing to revert empty account deletions when the transaction causing the deletions of empty accounts ended with an out-of-gas exception" caused issues with consensus on November 24 2016. Usually, ...
2
votes
0answers
164 views

What's reverted and not reverted during an Out of Gas exception?

A seemingly crucial question on EIP 158 was unanswered: Unless the empty accounts are deleted even in the case of an EVM exception, if that is the case would that not break the guarantee that ...
20
votes
2answers
7k views

Throw vs. Return

We're trying to figure out whether to use return or throw in Solidity when a condition fails and we don't assume user maliciousness. Here's the pros and cons we've figured so far: Why use throw Any ...
2
votes
2answers
1k views

Recursive call ends with `VM Exception: invalid opcode`

I am running f: contract Test { function f() { f(); } } which produces VM Exception: invalid opcode in browser-solidity. Is that a bug or expected behavior?
4
votes
1answer
351 views

Buy function not working with solidity 0.4.2

I don't know if there is any such change in latest Solidity version that is preventing execution of this function: function buy() returns (uint amount){ amount = msg.value / buyPrice; ...
3
votes
2answers
580 views

How to catch out of gas exception

As per my knowledge,there are no custom exceptions in solidity. The only exception is Out of Gas. Wherever we write throw in contract code, it throws out-of-gas exception. But, is there any way I can ...
14
votes
3answers
2k views

Does an entire transaction revert when throw occurs?

I have a contract that calls another contract that calls another. If there is a throw (or out-of-gas error) that occurs somewhere in the second contract, does the entire transaction get reverted or is ...
1
vote
1answer
28 views

Need help understanding Sharer(exceptions) example from docs

Ok, here's the code from solidity docs: contract Sharer { function sendHalf(address addr) returns (uint balance) { if (!addr.send(msg.value / 2)) throw; // also reverts the ...
4
votes
2answers
214 views

Logging errors in the fallback function

In the code I return any Ether sent by mistake to contract C with the throw; statement inside the fallback function. I also want to make a log of this occasion. The following code doesn't work(throw; ...
2
votes
0answers
322 views

Detecting exceptions in transactions

I've seen some suggestions from the community about managing throws in transactions using some different methods: Don't use a throw - use events for error checking Check using ...
2
votes
0answers
92 views

Reverting changes made during the transaction without throwing an exception

It's not possible to have custom exception messages with throw, is there a way to somehow find out which throw statement was executed (i.e. code line number)? Another approach I'm considering is to ...
7
votes
2answers
546 views

Custom Exceptions in Solidity

In solidity, is there any way to throw custom Exceptions along with error messages? I am using throw to prevent further execution of my code but this always results in invalid JUMP(in geth console, ...
1
vote
1answer
541 views

Checking if transaction failed over RPC

I call a contract over geth RPC using sendTransaction and get a transaction hash. Is there a way to verify over the geth RPC interface if this transaction failed due to a VM abort (Solidity throw ...
24
votes
2answers
2k views

Is it a good practice to log an event every time I throw in Solidity?

In Solidity (0.3.2) I am aware that there is no way to throw specific exceptions. (Everything is an invalid JUMP error.) It seems beneficial to have a way to log specific errors. Does it make sense to ...
1
vote
0answers
22 views

How does The DAO reimburse erroneous transactions to the sender? [duplicate]

Looking at the account of The DAO in a blockchain explorer, multiple transactions are marked as Error occurred during contract Execution. Most of the time this seems due to an out of gas exception, ...
5
votes
2answers
229 views

Running contract CrowdFunder in Mix and function modifier causes - Solidity exception (bad jump)

I'm experimenting with contract CrowdFunder which I found on the net https://github.com/nemild/learnxinyminutes-docs/blob/solidity/solidity.html.markdown and I'm getting an error Solidity exception ...
3
votes
1answer
1k views

Error During Token Contract Execution

Getting an error in executing a token contract: An error occurred during contract execution: invalid jump destination (PUSH1) 2 http://testnet.etherscan.io/vmtrace?txhash=...
4
votes
2answers
450 views

Throw not generated when accessing mapping with invalid key

I'm trying to implement the current contract: contract Mortal { address owner; event Killed(address indexed from); function Mortal() { owner = msg.sender; } function ...
4
votes
2answers
850 views

Does `throw` refund the ether value?

When a contract triggers a throw, the Solidity document states: Solidity will trigger an "invalid jump" and thus cause the EVM to revert all changes made to the state. In this case, what happens ...
22
votes
4answers
4k views

Why does a Solidity throw consume all gas?

When you throw an exception, all gas is consumed. What is the rationale for this design decision?