From ea39677e26cc90f54a1f0f341769353aed537476 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 18 Jul 2023 19:50:34 +0200 Subject: [PATCH 1/2] Add exception paragraph --- src/blog/jspi.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/blog/jspi.md b/src/blog/jspi.md index 62dc53f23..3de73379c 100644 --- a/src/blog/jspi.md +++ b/src/blog/jspi.md @@ -51,6 +51,10 @@ However, as with other Promise-style APIs in the browser, any time the WebAssemb JavaScript already has a well developed mechanism for representing asynchronous computations: the Promise and the `async` function notation. The JSPI is designed to integrate well with this but not to replace it. +### How do I deal with exceptions? + +To avoid having to deal with JSPI exceptions, you will probably want to avoid exposing your promise rejections to JSPI at all. That can be done by using `.then` to attach a rejection handler that returns the rejected promise into a successfully resolved promise that carries the error code your application is expecting. + ### Next steps The JSPI is currently experimental–one should not use it for Web applications that are intended to be deployed in production. However, it is a _standard track_ effort; which means that it will eventually become a standard and we expect this to become a standard implemented across all major browsers. From 9b54f90dc0ecab980c57df20ddda2c8019ceb7ca Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 18 Jul 2023 19:51:25 +0200 Subject: [PATCH 2/2] Update src/blog/jspi.md --- src/blog/jspi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blog/jspi.md b/src/blog/jspi.md index 3de73379c..b20eeebb7 100644 --- a/src/blog/jspi.md +++ b/src/blog/jspi.md @@ -53,7 +53,7 @@ JavaScript already has a well developed mechanism for representing asynchronous ### How do I deal with exceptions? -To avoid having to deal with JSPI exceptions, you will probably want to avoid exposing your promise rejections to JSPI at all. That can be done by using `.then` to attach a rejection handler that returns the rejected promise into a successfully resolved promise that carries the error code your application is expecting. +To avoid having to deal with JSPI exceptions, you will probably want to avoid exposing your promise rejections to JSPI at all. That can be done by using `.then()` to attach a rejection handler that returns the rejected promise into a successfully resolved promise that carries the error code your application is expecting. ### Next steps