Hide traceback in UserError message

Hi all, i want to show an user exception but i want that in the front-end the user only see the message, not the traceback. I have multiple clients that says that seeing all those texts are misleading and that they can’t focus on what are the errors that they made. Also they say that seeing all those lines with numbers and Files makes them feel unsafe in using the app.


In previous image you can see the line in which file produced the error, but the user doesn’t need to see this, it would be nice to only show the actual message to the user with a h2 or h3 title that says “Error in user input” or “User Error”, and then the message.


This is indeed something you normally don’t want to communicate with your users. Can you show me the line of code that produces the UserError? Since I’m not able to reproduce it. This doesn’t show a traceback for me:

raise UserError(ValueError("This is an error"))

What SDK version are you using?

Sure, this is the code:

    personalizacion_total_joints = personalizacion_dataframe["nodo"].to_numpy()
    joints_no_validos_en_personalizacion = np.setdiff1d(personalizacion_total_joints, joints_iniciales)

    if len(joints_no_validos_en_personalizacion) > 0:
        input_violation = InputViolation(
            "Error en Joints personalizados",

        raise UserError(ValueError(
            "Los siguientes Joints no hacen parte de la tabla de servico pero " +
            "están presentes en la tabla de Nodos personalizados. Debe eliminarlos de la" +
            "tabla de Nodos personalizados, o debe " + 
            f"especificar esos nodo en la tabla de servicio para continuar: {str(joints_no_validos_en_personalizacion)}"),

but this code its’n called from the app.py file, is from a python file where i put some utils functions. Then, this functions are called in a view in the app.py file.

You can directly pass in the string into UserError without the ValueError, not sure if that solves your problem.

Nevertheless, I expect it to work also in this form, I’m not able to reproduce it. So some additional questions:

  • What version of Python and what version of the SDK are you using?
  • Are you using the latest connector version? This would only affect local development though, not production. Upgrade with viktor-cli upgrade
  • What message do you see in the terminal?
1 Like

Hi, i review my code and i saw the error i was doing. I was raising the UserError in a function, and that function was in a try except statement with the except being like this:

        except Exception as e:
            raise UserError(traceback.format_exc())

So i was showing the traceback. My mistake.

1 Like