amos on Nostr: Usually there's two variants of a function in elixir, one that ends with ! and can ...
Usually there's two variants of a function in elixir, one that ends with ! and can throw an exception, and one that will return either {:error, result} or {:ok, result}.
I usually use the first option if I know there is no chance something will fail or I don't care if it fails, and the second option if I know there is a chance it will fail and I want to catch the error. Of course you can also catch exceptions, but I do that more as a catchall if I really don't want a process to crash.
Published at
2023-03-04 08:44:42Event JSON
{
"id": "fd4f63b675c8d2c13a592603b0f881ab0215f60e9c87ac2abcf263e803deef4a",
"pubkey": "9e87fe21542cef6b1076334f5e01f614cbc5bea223187b078deb47c2f72205b6",
"created_at": 1677919482,
"kind": 1,
"tags": [
[
"client",
"tucan.to"
],
[
"e",
"abfc419d051e252889ab5371256f4455fcb4f9040186eb4afa71356d2caecc3c",
"wss://relay.damus.io",
"root"
],
[
"p",
"52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd"
]
],
"content": "Usually there's two variants of a function in elixir, one that ends with ! and can throw an exception, and one that will return either {:error, result} or {:ok, result}. \nI usually use the first option if I know there is no chance something will fail or I don't care if it fails, and the second option if I know there is a chance it will fail and I want to catch the error. Of course you can also catch exceptions, but I do that more as a catchall if I really don't want a process to crash. ",
"sig": "201914ed396171e77431a79fd53dd522da74ebf7343c18f13334af04ed68125bbbfec9f645e20fe3fd7072f8e50445bbecb11791e37c615c0f7dbce97ac163cf"
}