Sending error message from server to user-interface

Hi guys, I am new to Jupyter Lab and I have been trying to do something but couldn’t. So the deal is that we want to transfer error message from the server side to somewhere in the front end. For example, here is an error message:

[E 2022-08-03 14:13:23.616 ServerApp] [Ploomber] An error occured when trying to initialize the pipeline. Cells won’t be injected until your pipeline processes correctly. See error details below.
Traceback (most recent call last):
File “/Users/xilinwang/Documents/ploomber/ploomber_fork/ploomber/src/ploomber/util/loader.py”, line 111, in _default_spec_load_generator
spec = DAGSpec(path_to_entry_point,…

It is showing only in the terminal where I run jupyter Lab. People sometimes don’t check it so I want it to be on my jupyter lab interface, maybe have a pop up tab displaying this error message. How can I achieve this? Thanks a lot! :smile:

I’m assuming this is a server extension. Is this an error raised handling a request? The standard way to do that is to include the message you want to propagate in the HTTP error message, e.g.

raise web.HTTPError(500, "specific custom message")

This should propagate to the client-side where the request is handled. If you’ve written the client side and it’s not showing errors, that may be because there’s missing error handling in the requests.

It’s trickier if this is an async error and not directly associated with any request - then you’d have to have some sort of notifications/messages API in your extension to collect async messages.

Yes, we have a server extension. We have a function triggered everytime users open a file as a notebook in jupyter lab, sometimes this function can fail, and its error message is showing in the terminal, we want it to be displayed on jupyter side. I am fairly new to jupyter, how do i write code in client side? I saw some thing online to write js code for client extension, but I don’t know where do I write them and how do I enable them. Thanks for your reply!

How are you hooking in your code to every time a file opens? If it causes the actual ContentsManager.get to raise, an error should propagate to the user, preventing the file from opening.