Solidity REPL
Contracts & calls

Try and catch a revert

Call a contract that reverts and handle the result without ending the run.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to test contract composition, external calls, events, and return values inside one reproducible run. The entry isolates try and catch a revert so its input, result, and state changes stay easy to compare.

Solidity to run

contract Flaky {
  function check(uint256 value) external pure returns (uint256) {
    require(value > 10, "too small");
    return value;
  }
}
Flaky flaky = new Flaky()
uint256 result
try flaky.check(3) returns (uint256 value) { result = value; } catch { result = 99; }
result

What to expect

The external call reverts for value 3, the catch branch handles it, and the final result is 99.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about calls and logs Reproducible investigation