-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle runtime errors #104
Comments
@csgui to see if this is still an issue. |
This is still an open item. |
Thanks @obycode |
Note: On the file below, some tests are being ignored due this issue. Remove
|
In standard.wat, we have defined the function ;; The error code is one of:
;; 0: overflow
;; 1: underflow
;; 2: divide by zero
;; 3: log of a number <= 0
;; 4: expected a non-negative number
;; 5: buffer to integer expects a buffer length <= 16
;; 6: panic
;; 7: short return
(func $stdlib.runtime-error (param $error-code i32)
;; TODO: Implement runtime error
unreachable
) This
Instead, we need to catch this wasm runtime error, and convert it to a clarity error, based on that error code that is passed into this function. For example:
This should happen wherever we
top_level
.call(&mut store, &[], results.as_mut_slice())
.map_err(|e| Error::Wasm(WasmError::Runtime(e)))?;
|
After these errors are properly mapped, then we should remove the |
Fixed by #379 |
In
initialize_contract
andcall_function
, we'll need to handle runtime errors correctly. That includes mapping the traps from our standard library functions to the standard Clarity errors, and also mapping errors from host-interface functions back to clarity errors.The text was updated successfully, but these errors were encountered: