| 2 | const PREFIX2 = "Returned error: VM Exception while processing transaction: "; |
| 3 | |
| 4 | async function tryCatch(promise, message) { |
| 5 | try { |
| 6 | await promise; |
| 7 | throw null; |
| 8 | } catch (error) { |
| 9 | assert(error, "Expected an error but did not get one"); |
| 10 | try { |
| 11 | assert( |
| 12 | error.message.startsWith(PREFIX + message), |
| 13 | "Expected an error starting with '" + PREFIX + message + "' but got '" + error.message + "' instead" |
| 14 | ); |
| 15 | } catch (err) { |
| 16 | assert( |
| 17 | error.message.startsWith(PREFIX2 + message), |
| 18 | "Expected an error starting with '" + PREFIX + message + "' but got '" + error.message + "' instead" |
| 19 | ); |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | module.exports = { |
| 25 | catchRevert: async function(promise) { |