statement_try_catch_call.sol 596 B

123456789101112131415161718192021
  1. contract aborting {
  2. function abort() public returns (int32, bool) {
  3. revert("bar");
  4. }
  5. }
  6. contract runner {
  7. function test() public {
  8. aborting abort = new aborting();
  9. try abort.abort() returns (int32 a, bool b) {
  10. // call succeeded; return values are in a and b
  11. } catch Error(string x) {
  12. if (x == "bar") {
  13. // "bar" reason code was provided through revert() or require()
  14. }
  15. } catch (bytes raw) {
  16. // if no error string could decoding, we end up here with the raw data
  17. }
  18. }
  19. }