Created
October 9, 2024 14:52
-
-
Save jorgevilaca82/afac7f88bb435920b9e0b7c7954dbaaa to your computer and use it in GitHub Desktop.
Error module
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
defmodule Error do | |
defstruct code: nil, message: nil, details: nil | |
@doc """ | |
Creates a new error struct | |
## Usage: | |
iex> Error.new("E001", "This is an error") | |
or with opts: | |
iex> Error.new("E001", "This is an error", details: [id: "XPTO-001"]) | |
""" | |
def new(code, message, opts \\ []) do | |
%__MODULE__{code: code, message: message} | |
|> struct(opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment