Giter Site home page Giter Site logo

Improve Error Messages about vrl HOT 5 CLOSED

martinrupp avatar martinrupp commented on May 28, 2024
Improve Error Messages

from vrl.

Comments (5)

bsumirak avatar bsumirak commented on May 28, 2024

I want to stress the point Martin has made here.
Error messages (not only when triggered by groovy code), do not provide enough detail, yet!
Especially the location of the error (at least: file and line; better: also class and method) should absolutely be included in any message (perhaps not necessarily on the canvas, but definitely in the log).
This would really help during debugging!

from vrl.

miho avatar miho commented on May 28, 2024

I've improved the msg for project code. As Martin suggests, the deepest msg is shown:

bildschirmfoto 2014-01-13 um 15 48 52

Especially the location of the error (at least: file and line; better: also class and method) should absolutely be included in any message (perhaps not necessarily on the canvas, but definitely in the log).

The behavior depends on the message type. If it is an exception all available information will be shown in the log. If it is an error message, such as Cannot establish connection, there is no line number since this message is not based on an exception.

Please give some examples of error messages that do not behave as expected.

from vrl.

bsumirak avatar bsumirak commented on May 28, 2024

Thank you, Michael, for the partial fix.

Now, for example, I stumbled upon an exception caught in eu.mihosoft.vrl.io.vrlx.AbstractWindows, line 93:

for (AbstractWindow o : this) {
    try {
        CanvasWindow w = o.addToCanvas(mainCanvas);

        windows.add(new Pair<CanvasWindow, AbstractWindow>(w, o));

    } catch (Exception ex) {
        mainCanvas.getMessageBox().addUniqueMessage(
                "Error while loading windows!",
                ex.toString()
                + "  in method " + ex.getStackTrace()[0].getClassName()
                + ":" + ex.getStackTrace()[0].getMethodName()
                + "   in file: " + ex.getStackTrace()[0].getFileName()
                + ":" + ex.getStackTrace()[0].getLineNumber(),
                null, MessageType.ERROR);
        ex.printStackTrace(System.out);
        if (ex.getCause() != null) {
            mainCanvas.getMessageBox().addUniqueMessage("Error Message!",
                    ex.getCause().toString(), null, MessageType.ERROR);
        }

        Logger.getLogger(AbstractWindows.class.getName()).
                log(Level.SEVERE, null, ex);
    }
}

This exception is only displayed on Canvas (not in the log in the application) and, unfortunately, no information as to where it originated is printed anywhere. This one was quite a bit of a nuisance to me until I finally found out where it came from.

Another example is in eu.mihosoft.vrl.reflection.TypeRepresentationBase in line 1372:

try {
    ...
} catch (Exception ex) {

    ex.printStackTrace();

    if (getMainCanvas() != null) {
        MessageBox mBox = getMainCanvas().getMessageBox();

        String message = ex.toString();

        if (ex.getCause() != null) {
            message += "\n>> " + ex.getCause().toString();
        }

        mBox.addUniqueMessage("Can't evaluate value options:",
                "Class " + getType().getName() + "<br>" + ">> "
                + message, getConnector(), MessageType.WARNING);

    }
    Logger.getLogger(TypeRepresentationBase.class.getName()).
            log(Level.SEVERE, null, ex);
}

Again, a message is displayed on the Canvas, yet no clue where the exception originates from.

In both cases, at least ex.getStackTrace()[0].getFileName() and ex.getStackTrace()[0].getLineNumber() could be called and the information be displayed. Personally, I would like to get a full stack trace in the log.

I suppose there will be more examples of that kind, however, those two have been in my particular way.

from vrl.

miho avatar miho commented on May 28, 2024

New logging behaviour:

VRL registers a custom log handler to further improve the error output. Every logger that uses parent handlers via rootLogger.setUseParentHandlers(true); will be redirected to the log window. For loggers that don't use their parents redirection does not work since they can redirect to streams/files that are unknown. However, for most loggers this should be no problem.

Loggers with Level = SEVERE and Level = WARNING redirect to VRLs custom err stream. All others redirect to VRLs custom out stream.

Please report whether this fix works for you.

from vrl.

miho avatar miho commented on May 28, 2024

no activity

from vrl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.