Catch an exception
Options
Luck Kanthatham-2308338
Member ✭
I've converted an API end point with a precondition set to enforce that data is returned. Now that this is a function, is it possible that the calling function can catch exception from the precondition in the function and do something with it?
sequence:
1. main function calls the function
2. function fails based on the precondition and generates an exception
3. currently, the main function exits with the exception from step 2
I'd like to be able to catch the exception from step 2 and continue down the main function.
sequence:
1. main function calls the function
2. function fails based on the precondition and generates an exception
3. currently, the main function exits with the exception from step 2
I'd like to be able to catch the exception from step 2 and continue down the main function.
Comments
-
In general, if there's a way to do some kind of try/catch, it would be extremely useful.
-
Xano doesn't do try/catch but you should be able to accomplish the same thing with conditionals and preconditions
-
Thank you, Michael.
-
Wow, that's a big difference from traditional development.
Just experienced this after doing some basic check:
const { DateTime, Duration } = luxon; // See https://docs.xano.com/working-with-data/lambdas-javascript/libraries-and-functions#luxon const { sunday, employeeId } = $input; const date = DateTime.fromISO(sunday); // If date isn't a sunday, stop the script if (date.weekday !== 7) { throw new Error(`The provided date is not a Sunday "${sunday}". The provided date must be a Sunday but is a "${date.weekdayLong}", because the script will generate a Weekly Timesheet (7 days), starting by the week's Sunday.`); }
But even when this script was failing, the rest of the actions was executed, not quite what I had expected!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback