havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
szkl has quit [Quit: Connection closed for inactivity]
teclator has quit [Ping timeout: 244 seconds]
teclator has joined #ruby
Shortstop has joined #ruby
victori has quit [Quit: ZNC 1.8.2 - https://znc.in]
victori has joined #ruby
c10l60 has joined #ruby
c10l6 has quit [Ping timeout: 244 seconds]
c10l60 is now known as c10l6
Vonter has joined #ruby
caedmon has joined #ruby
caedmon has quit [Ping timeout: 260 seconds]
caedmon has joined #ruby
hd1 has joined #ruby
hd1 has left #ruby [#ruby]
caedmon has quit [Ping timeout: 244 seconds]
caedmon has joined #ruby
Linux_Kerio has joined #ruby
_ht has joined #ruby
reset has quit [Quit: reset]
Sankalp has quit [Ping timeout: 245 seconds]
Sankalp- has joined #ruby
Sankalp- is now known as Sankalp
caedmon has quit [Ping timeout: 246 seconds]
Shortstop has quit [Quit: Client closed]
infinityfye has joined #ruby
_ht has quit [Remote host closed the connection]
rvalue has quit [Ping timeout: 264 seconds]
rvalue has joined #ruby
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 240 seconds]
rvalue- is now known as rvalue
TomyWork has joined #ruby
John_Ivan_ has joined #ruby
John_Ivan has quit [Ping timeout: 250 seconds]
MarvelousWololo has quit [Read error: Connection reset by peer]
Linux_Kerio has quit [Ping timeout: 246 seconds]
indent67 has joined #ruby
jvalleroy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jvalleroy has joined #ruby
duderonomy has quit [Ping timeout: 244 seconds]
duderonomy has joined #ruby
shokohsc55 has joined #ruby
shokohsc5 has quit [Ping timeout: 250 seconds]
shokohsc55 is now known as shokohsc5
Linux_Kerio has joined #ruby
konsolebox has joined #ruby
lena64t has joined #ruby
indent67 has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]
jvalleroy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<sarna> how do you implement functions that can return a success or a failure? throwing an exception wouldn't be appropriate as failures are expected
<sarna> I've been thinking about just returning an exception instead of throwing it, but it feels iffy
jvalleroy has joined #ruby
smp has quit [Remote host closed the connection]
smp has joined #ruby
<Momentum> throwing an exception is the right way to handle exceptions AFAIK
<sarna> yeah, in normal circumstances where errors are rare. I have failures that are likely to happen
<leftylink> the most natural fit is Either or Option, but since Ruby doesn't have either of those this isn't an option. there doesn't seem to be one obvious natural fit
<leftylink> I haven't seen returning an exception being used before but I don't hate the idea any more than other alternatives
<ox1eef_> Maybe true or false. Or a Result struct (class Result < Struct.new(:success)).
<ox1eef_> You could implement success? and failure? on top of the struct.
<sarna> yeah I'm trying not to overdo it with the wrapping, at some point it's more trouble than it's worth..
<ox1eef_> If I had to avoid exceptions, I would use Result, with: #success?, #failure?, and #failure_reasons or something like that. I would probably want to communicate the why rather than just a generic "it failed".
<ox1eef_> Keep in mind it would be a custom pattern that might surprise other Ruby programmers.
<sarna> maybe let me explain my use-case a bit better: I run an action over bundles of data, and then I report (to the user) for which bundles it ran okay, and for which bundles it failed and why
<sarna> how would you normally do it in ruby?
<sarna> I can't imagine using exceptions for that, and then rescuing them to push some stuff in the array with run results
<ox1eef_> Ah I see. I would probably have an array of Result objects then, one for each bundle.
<ox1eef_> Easy to filter that way as well: results.select(&:success?), results.select(&:failure?).
<sarna> maybe it could even be more specific, right? not a generic `Result` but something like `RunResult`
<sarna> not to scare people away with monads
<ox1eef_> Sure.
<sarna> I've also been thinking about doing something like `[:ok, 123]` & [:error "it exploded!"]` or `{ok: 123}` & `{error: "it exploded!"}`
<sarna> but I'm not sure about the ergonomics/rubyness here.. probably too "primitive obsessed"
<ox1eef_> That works, but probably easier to work with an object.
<sarna> gotcha. thanks for the help :)
<ox1eef_> No worries.
konsolebox has quit [Quit: Leaving]
weyhmueller has quit [Quit: ZNC - https://znc.in]
yosafbridge` has quit [Quit: Leaving]
weyhmueller has joined #ruby
yosafbridge has joined #ruby
konsolebox has joined #ruby
user23 has joined #ruby
infinityfye has quit [Ping timeout: 244 seconds]
lena64t has quit [Remote host closed the connection]
lena64t has joined #ruby
cahoots has joined #ruby
<dorian> z
lena64t1 has joined #ruby
cahoots has quit [Client Quit]
lena64t has quit [Ping timeout: 240 seconds]
joshcom has joined #ruby
infinityfye has joined #ruby
donofrio has quit [Read error: Connection reset by peer]
user23 has quit [Remote host closed the connection]
lena64t1 has quit [Quit: WeeChat 4.1.0-dev]
joshcom has quit [Quit: Leaving]
<johnjaye> ox1eef_: i just realized I know nothing about how exception handling works in ruby
<johnjaye> is that what you were talking about
MarvelousWololo has joined #ruby
passbe has quit [Quit: bye...]
passbe has joined #ruby
xuochi has joined #ruby
cata has quit [Quit: WeeChat 3.8]
_ht has joined #ruby
<leftylink> no, exceptions are for failures are exceptional and not expected. the discussion was about when failures are expected and a regular occurrence
<leftylink> in such a case exceptions are inappropriate
nkm has joined #ruby
reset has joined #ruby
gh0st6 has joined #ruby
teclator has quit [Ping timeout: 250 seconds]
TomyWork has quit [Remote host closed the connection]
keypresser86 has quit [Remote host closed the connection]
keypresser86 has joined #ruby
polychromata has quit [Ping timeout: 250 seconds]
polychromata has joined #ruby
A_Dragon has quit [Killed (Stx (Happy birthday! (I know its a bit late) She: Yes it does.))]
A_Dragon has joined #ruby
caedmon has joined #ruby
nkm has quit [Quit: Client closed]
nkm has joined #ruby
xuochi has quit [Quit: leaving]
nkm has quit [Quit: Client closed]
gh0st6 has quit [Quit: Connection closed for inactivity]
Laplace has quit [Quit: Connection closed for inactivity]
Linux_Kerio has quit [Ping timeout: 250 seconds]
_ht has quit [Remote host closed the connection]
svdasein has joined #ruby
svdasein_ has joined #ruby
dnadev2 has quit [Ping timeout: 245 seconds]
caedmon has quit [Ping timeout: 245 seconds]
shokohsc5 has quit [Ping timeout: 244 seconds]
shokohsc51 has joined #ruby
infinityfye has quit [Quit: Leaving]
John_Ivan_ has quit [Quit: Disrupting the dragon's slumber one time too often shall eventually bestow upon all an empirical and indiscriminate conflagration that will last for all goddamn eternity.]
John_Ivan has joined #ruby
teclator has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
helge has quit [Ping timeout: 252 seconds]
wnd has quit [Quit: Caught sigterm, terminating...]
wnd has joined #ruby
helge has joined #ruby
desnudopenguino has quit [Remote host closed the connection]
desnudopenguino has joined #ruby
teclator has quit [Ping timeout: 264 seconds]
keypresser86 has quit [Read error: Connection reset by peer]
keypresser86 has joined #ruby