Giter VIP home page Giter VIP logo

Comments (3)

aroberge avatar aroberge commented on August 25, 2024

Here's a first example:

import friendly
import logging

logging.basicConfig(filename="ignore.log")
friendly.set_lang('fr')

a = 1
b = 0
try:
    c = a / b
except Exception:
    friendly.explain_traceback(redirect="capture")
    result = friendly.get_output()
    logging.error(result)

And here's the output file

ERROR:root:
Traceback (most recent call last):
  File "ignore.py", line 10, in <module>
    c = a / b
ZeroDivisionError: division by zero

    Une exception de type `ZeroDivisionError` se produit lorsque vous essayez de diviser une valeur
    par zéro soit directement ou en utilisant une autre opération mathématique.
    
    Vous divisez par le terme suivant
    
         b
    
    qui est égal à zéro.
    
    Exception levée à la ligne 10 du fichier ignore.py.
    
        8: b = 0
        9: try:
    -->10:     c = a / b
                   ^^^^^
       11: except Exception:

            a:  1
            b:  0

from friendly.

AlvesInfo avatar AlvesInfo commented on August 25, 2024

génial, c'est tout à fait ça!
Mercii!!

from friendly.

aroberge avatar aroberge commented on August 25, 2024

@AlvesInfo J'ai rajouté une section dans la documentation (en anglais) avec une explication supplémentaire qui pourrait être utile.
Le lien est le suivant: https://aroberge.github.io/friendly-traceback-docs/docs/html/usage.html#logging

from friendly.

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.