[![Master](https://travis-ci.org/smartcitiesdata/yeet.svg?branch=master)](https://travis-ci.org/smartcitiesdata/yeet)
[![Hex.pm Version](http://img.shields.io/hexpm/v/yeet.svg?style=flat)](https://hex.pm/packages/yeet)
# YEET
Generates standard messages for Dead Letter Queue
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `yeet` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:yeet, "~> 1.0"}
]
end
```
## Usage
```
Yeet.format_message(app_name, original_message, options \\ [])
```
Options:
- stacktrace: generated by the language
- exit_code: Often there are errors/exceptions inside exits. Exits are often wrapped by the caller and provide stacktraces too.
- error: decided by app for error tracing
- reason: human useful description of error
- timestamp: time marker, defaults to now
### Example Output Message Shape
```elixir
%{
app: "forklift",
original_message: "{\"topic\": "\streaming-raw\", ...}",
stacktrace: " :erlang./(1, 0)",
exit_code: "%RuntimeError{message: \"Error\"}",
error: "FORKLIFT-PARSE"
reason: "Failed to parse message",
timestamp: #DateTime<2018-09-11 11:11:00Z>
}
```
## Example generation snippets
### Stacktrace
```
iex(1)> System.stacktrace
[
{:erl_anno, :anno_info, [{1, 18, 1}], [file: 'erl_anno.erl', line: 375]},
{IEx.Evaluator, :loop, 1, [file: 'lib/iex/evaluator.ex', line: 103]}
...
...
]
```
```
iex(2)> Process.info(self(), :current_stacktrace)
{:current_stacktrace,
[
{Process, :info, 2, [file: 'lib/process.ex', line: 767]},
{:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]},
{:elixir, :eval_forms, 4, [file: 'src/elixir.erl', line: 258]},
{IEx.Evaluator, :handle_eval, 5, [file: 'lib/iex/evaluator.ex', line: 257]},
{IEx.Evaluator, :do_eval, 3, [file: 'lib/iex/evaluator.ex', line: 237]},
{IEx.Evaluator, :eval, 3, [file: 'lib/iex/evaluator.ex', line: 215]},
{IEx.Evaluator, :loop, 1, [file: 'lib/iex/evaluator.ex', line: 103]}
]}
```
### Exit Codes
```elixir
exit_code =
try do
raise "Error"
rescue
e -> e
end
```
### Timestamp
```
iex(3)> DateTime.from_iso8601("2018-09-11 11:11:00Z")
{:ok, #DateTime<2018-09-11 11:11:00Z>, 0}
```