PricingBlog

How do you manage error logging?

  • neville9288-1506011283525206164

    Neville

    1 month ago

    Hello folks!

    I'm interested to hear how you handle error logging in your app. Here's what I am trying to figure out:

    I would like to add error handling to each API call. Some errors will be surfaced in the UI only, and some will be surfaced in the UI as well as recorded in an error_log table.

    The problem is that some pages contain 2 or 3 API endpoints, and potentially each needs error handling.

    Workflows do some of this, but a) I would have to re-create this on every page with API calls and b) they don't encapsulate the error logging api call.
    Components do some of this (encapsulation) but I would need a workflow to set each attribute and then toggle an attribute that fires the error logging api call.

    I'm sure I am not the first and pretty sure I am overlooking a simple solution. Any pointers highly appreciated - thanks!
  • jacobkofoed-1506014778504511659

    Jacob Kofoed

    1 month ago

    I don’t have a similar case yet, but I imagine that I would have an ‘error-boundary’ component in the root of my page that has a workflow called “Log error” with parameters for UI only, title, code and description and expose the workflow in context and call it on each API.

    Maybe that’s what you tried already but didn’t quite cut it for you?
  • neville9288-1506034555147255869

    Neville

    1 month ago

    That's pretty much what I had in mind Jacob, thanks. I will experiment and post back here when I have something working.
  • neville9288-1506240670367485973

    Neville

    29 days ago

    I eventually went for a JS action that logs an error to the error_log table. This is global to the project so I can wire it up to each API call's on error event (or handle otherwise as appropriate). The table does not require authentication but I'm OK with that. Inputs are specific to my app. The Xano CORS settings by default allows all origins - I will probably lock that down before I go live.

    Hope this helps if you get similar questions in future!
    1506240670883381248-Screenshot_2026-05-19_at_5.14.49_AM.png
    🙌1
  • jacobkofoed-1506241043140710441

    Jacob Kofoed

    29 days ago

    Smart solution 👍
  • neville9288-1506241101730807808

    Neville

    29 days ago

    thanks 🙂
  • max.kayr-1506249507959078983

    Max

    29 days ago

    Hey! Why did you choose a custom action over a workflow that you make available via a context?
  • neville9288-1506256428950749244

    Neville

    29 days ago

    I need this to work across all the pages in my app, and I think making a global action was the only way to do it. As far as I know workflows are local to a page only?
  • max.kayr-1506258849013698642

    Max

    29 days ago

    You can create a component like error-context that has a workflow logError and just a slot as the content. So it does not really render anything. It just has the logic. Then you can put that component error-context on each page. All its children have access to the logError flow. Does that make sense?
  • neville9288-1506259707579469864

    Neville

    29 days ago

    that does and I did look at it, but I decided not to use it because of the way I would have to wire up the attributes of the component to log the error. Some pages have 3 or 4 api calls (dashboard stuff), so for each on error I would need to set the appropriate attributes and toggle a "log error now" attribute.

    Not sure if my understanding of NC capabilities is up to speed, but that's where I ended.
  • max.kayr-1506260979107889182

    Max

    29 days ago

    Ah, I see! On pages, I personally do not use API calls. Pages are just containers for components. I don't put any logic there. So in my apps, the calls are in components and therefore have access to the logError flow
  • neville9288-1506262239060033597

    Neville

    29 days ago

    that's an interesting design pattern, I will think about that one. One of the challenges I have as a solo developer is that I can easily fall into design patterns that are not optimal. This idea changes how I think about app design... I will think about this for a bit because I do have some master-detail layouts that I may need to adapt if I go this way.

    Thanks Max.
    💪1
  • jacobkofoed-1506263874851176519

    Jacob Kofoed

    29 days ago

    I also noticed that on long lived projects. that pages just keep growing with formulas and workflows as they are effectively the global-store, but by separating the logic into pure provider components, like Max suggests, it is much easier to work with. That said, stateless global actions are great for simple use-cases as well, but if you have to pass in a bunch of parameters that the provider could gather itself from context, then its probably better to use provider components.
  • neville9288-1506264765666693212

    Neville

    29 days ago

    wiring up the error handler is relatively simple at the moment (see screenshot), but I totally get the point and will be looking at this in a lot of detail over the next couple of days. I'm all for simplicity - building this for the long haul, so anything I can do to make maintenance easier is A Good Thing. 🙂
    1506264766367400038-Screenshot_2026-05-19_at_6.56.55_AM.png
    👍1