Report socket failures as reasons, not as MatchError messages - #7
Merged
Conversation
Protocol wrapped :gen_tcp.send and :gen_tcp.recv in a match on success, so a
socket that timed out or closed mid-call left a MatchError whose message quoted
the raw {:error, :timeout} tuple. Everything above it rescues and stringifies,
so that message was the whole account of the failure a caller ever got.
URP.SocketError carries the reason :gen_tcp reported instead, which is the thing
a caller wants to act on.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A conversion could fail because soffice refused the document or because soffice
stopped answering, and both arrived as {:error, <string>}. A caller had nothing
to branch on: retrying a refused document is pointless, and a wedged soffice is
not the document's fault.
Socket failures now come back as the atom :gen_tcp reported, so :timeout,
:closed or a POSIX error, and everything soffice itself said stays a message
string. The bang functions re-raise a socket reason as the URP.SocketError it
was, so they still raise something with a readable message.
Callers that assumed every reason was a binary have to handle both shapes, hence
the minor version.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
URP.Protocolwrapped:gen_tcp.sendand:gen_tcp.recvin a match on success, so a socket that timed out or closed mid-call raised aMatchError. Every layer above rescues and stringifies, so the only account a caller got of a timed-out conversion was this:Two changes:
URP.Protocolnow raisesURP.SocketError, which carries the reason:gen_tcpreported.URP.convert/2and friends return that reason as an atom —:timeout,:closed, a POSIX error — while anything soffice itself said stays a message string. That is the distinction a caller actually needs: retrying a document soffice refused is pointless, and a wedged soffice is not the document's fault. The bang functions re-raise a socket reason as theURP.SocketErrorit was, so they still raise something with a readable message.Breaking for callers that assumed every reason was a binary, so this wants a minor bump. VERSION and the changelog heading are left alone —
release.sh minorcuts those.Tests cover both reasons over a real socket pair, a body that stops arriving mid-frame, a send to a dead socket, the message wording, and an atom reason passing through
checkout_outcome/4.mix test,mix format --check-formatted,mix dialyzer,mix xref graph --format cyclesandmix docs --warnings-as-errorsall pass locally; the integration suite against a real soffice has not been run here.