How to Record API Function Stack Errors for Later Analysis
![KenJ](https://us.v-cdn.net/6037124/uploads/userpics/22CE20SXDPY7/nM63D6JSW2HKB.jpg)
HI, I am builing API function stacks, but want to log to the database a meaningful message if something on the function stack creates an error.
Because under normal circumstances, if my front end sends data thats not quite right or I make a mistake in the function stack and it creates an error, how can the error be caught and analysed when the system in in production?
I have a helper global function that can write to my error log table, but when the function stack halts doe to an error I can't seem to save this error in any controlled way.
What I see is the error sent back to the front end to deal with but how can the error be recorded anyway in the backend?
Thanking you
Answers
-
Hey Ken
Have you tried using a Try/Catch for this? Here's a video about it.
-
Hi, I see Try/Catch is wrapped around functions.
But I am finding the error occurs sometimes right up front for example when an integer input receives a text input value and this instantly triggers an ERROR.
I cant see how Try/Catch can intercept this type of ERROR or is there some other way to catch these errors?
Thanking you,
-
Yes i dont think you can catch parameter validations using try/catch, and i think this would be a frontend error because the input from the frontend is wrong and imo i dont think we have to log this.😀
however you can wrap your whole api function in try/catch and use throw to send the error msg and code.
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