🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #90815

Libraries using longjmp for error handling (was: Re: More on NNTP testing)

#90815
From: Blue-Maned_Hawk
Date: Wed, 27 Sep 2023 22:52
37 lines
4215 bytes
Richard Kettlewell wrote:

> It’s more than 20 years since I last had to integrate a C library which
> reported errors via longjmp() and I’m still bitter about it.

I have never encountered a library which does that.  Which library was 
that?

> As a matter of API design, I’d rather C library communicated errors via
> return values (and pointer parameters, where more complex error
> information is required).

Personally, i think that, at least for a library, an error should _only_ 
be communicated by return value.  If more complex information is required, 
then the return value can be made more complex.  I don't think i've ever 
used a library that communicates information via a pointer parameter.

One thing i've experienced in multiple libraries is a system a bit like 
what errno.h offers, but done via a pair of subroutines that retrieve and 
assign to some hidden global variable.  I don't like this for the same 
reason i don't like subroutines that use errno (unless they're syscall 
wrappers), but in at least two of the cases the library has also come with 
a way to set a callback subroutine to automatically deal with errors 
instead.  This is nice, since it means that the code doesn't get all 
obfuscated with error checking after every subroutine call, but it's 
annoying that each library needs to come with its own unique subroutine 
for this, and i do worry about it being overly general in treating all 
errors lethally.



-- 
Blue-Maned_Hawk│shortens to 
Hawk│/
blu.mɛin.dʰak/
│he/him/his/himself/Mr. bluemanedhawk.github.io
Warning:  Low flying owls.  Lost chihuahua.
Technical Details
Message-ID: <pan$6f4ce$6edf891e$2b5c40c1$f8f989c1@invalid.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
References: <65SQM.565977$9o89.411905@fx05.ams4>

Show Full Headers
Complete Article Headers
Message-ID: <pan$6f4ce$6edf891e$2b5c40c1$f8f989c1@invalid.invalid>
Subject: Libraries using longjmp for error handling (was: Re: More on NNTP testing)
Date: Wed, 27 Sep 2023 22:52:59 +0000
From: Blue-Maned_Hawk <bluemanedhawk@invalid.invalid>
References: <65SQM.565977$9o89.411905@fx05.ams4>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: news.software.nntp,comp.lang.c
Followup-To: comp.lang.c
Organization: A noiseless patient Spider
Lines: 37
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 22:52:59 -0000 (UTC)
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:OQANcn/gOf9zbtXJAZnpDa7qS3U=
X-Face: Llanfair­pwllgwyngyllÂà ƒƒ‚­gogery­chwyrnàƒ‚Ãƒƒ‚­drobwll­llanàƒƒƒ‚­tysilio­gog o­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
 MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
 ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
 rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
 jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
 0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
 z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
 fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
 R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
 O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSj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