Giter VIP home page Giter VIP logo

Comments (7)

alranel avatar alranel commented on June 1, 2024

Yeah, I in a couple cases I suppressed the exit(1) calls with plain returns (when applicable). Most exceptions are related to IO or defensive programming checks. I think your idea is fine.

from admesh.

gladk avatar gladk commented on June 1, 2024

Hi Miro,

I am not an active admesh user/developer. If you do not break admesh
itself - I will accept most of changes.

I have actually uploaded already updated admesh version into Debian [1]. It
has
already admesh, libadmesh1, libadmesh-dev and dbg-version. Would be
good to tag a newer version on GitHub to get it uploaded before the next
Debian freeze (deadline is 5th of November, but I would prefer to have one
month
to fix possible bugs).

[1] https://packages.qa.debian.org/a/admesh.html

Cheers

Anton

2014-07-04 23:23 GMT+02:00 Miro Hronฤok [email protected]:

As admesh was never intended to be a library, it calls exit() on error.
That is not very developer friendly, as if someone uses admesh as a
library, he/she cannot catch the error and display it to the user properly.

I was thinking how to solve this problem without breaking the API by
changing all the void functions to int returning a susses/failure
information.

My idea is to add int error to stl_file structure. When a function call
fails, it would not exit, but instead just raises the error flag by setting
stl->error to 1.

When the error flag is raised, no other function would do anything.
Developer might want to clean the flag, that would be possible by some
function like stl_clean_error_flag() (or rewriting the error value back
to 0 manually). For safe usage, after all function calls, the developer
should check the error flag and do whatever he/she wants about it: display
an error message, exit, or do something completely different.

For convenience I plan a function stl_exit_on_error() that would clean
the memory and exit.

I do not plan to store textual information about what happened, because
there are only few places when an exit is happening now and it is pretty
clear form the context.

I would like to hear some thoughts about this from others, especially from
@alexrj https://github.com/alexrj -> would this be acceptable for
slic3r? I think you have deleted some exit statements already and the error
detection might be nice... ?

cc @gladk https://github.com/gladk @kliment https://github.com/kliment
@iXce https://github.com/iXce

โ€”
Reply to this email directly or view it on GitHub
#4.

from admesh.

hroncok avatar hroncok commented on June 1, 2024

Should be no problem.

from admesh.

hroncok avatar hroncok commented on June 1, 2024

@gladk Could you do some testing please?

from admesh.

hroncok avatar hroncok commented on June 1, 2024

@gladk There is 0.98.0alpha released.

from admesh.

jirutka avatar jirutka commented on June 1, 2024

I'm getting warning about calling exit from openSUSE build tool even for the latest version (0.98.3):

[    9s] admesh-libs.x86_64: W: shared-lib-calls-exit /usr/lib64/libadmesh.so.1.0.0 exit@GLIBC_2.2.5
[    9s] This library package calls exit() or _exit(), probably in a non-fork()
[    9s] context. Doing so from a library is strongly discouraged - when a library
[    9s] function calls exit(), it prevents the calling program from handling the
[    9s] error, reporting it to the user, closing files properly, and cleaning up any
[    9s] state that the program has. It is preferred for the library to return an
[    9s] actual error code and let the calling program decide how to handle the
[    9s] situation.

from admesh.

hroncok avatar hroncok commented on June 1, 2024

Yes, the function that calls exit is still there, but it's called exit_on_error. I think it's handled pretty reasonable now given the mess this "library" is.

from admesh.

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.