diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-25 10:32:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-25 10:32:41 +0530 |
| commit | 0bf85a7a812bef9eec097710f92c490c0ed9719a (patch) | |
| tree | afe6e9d1c4969d7b42466dcc3157e78b5c7785ac | |
| parent | 0665e6a2490c9ea770a98908788a1e5d210aa811 (diff) | |
| download | css-everything-0bf85a7a812bef9eec097710f92c490c0ed9719a.tar.gz css-everything-0bf85a7a812bef9eec097710f92c490c0ed9719a.zip | |
feat: scoped try error handling with error property
| -rw-r--r-- | TODO.norg | 2 | ||||
| -rw-r--r-- | examples/form/signup.css | 5 | ||||
| -rw-r--r-- | src/eval.ts | 4 |
3 files changed, 9 insertions, 2 deletions
@@ -5,6 +5,8 @@ - (x) re-quotify value - (x) analog + digital clock example - (x) error handling try + - ( ) Scoped catch on try + - ( ) `do` expression - ( ) `has-class` - ( ) `add-class` & `remove-class` should use self if id is not specified? - ( ) Update `--cssx-text` on update diff --git a/examples/form/signup.css b/examples/form/signup.css index 3433b87..3811c42 100644 --- a/examples/form/signup.css +++ b/examples/form/signup.css @@ -29,7 +29,10 @@ --cssx-on-submit: prevent-default() add-class(form, 'submitting') - request('/examples/') + try( + request('https://jksldjflksdjlfsd.com/wow'), + js-eval(string('alert("', get-var(--error), '")')) + ) remove-class(form, 'submitting') add-class(form, 'submitted') ; diff --git a/src/eval.ts b/src/eval.ts index 0be3de5..17e27b1 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -326,7 +326,9 @@ const getFunctions = ( try { return await evalExpr(args[0], actions) } catch (e) { - return evalExpr(args[1], actions) + return actions.evaluateInScope([args[1]], { + '--error': EvalValue.Value(e), + }) } }, |
