Packages
protox
2.0.1
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
2.0.0-dev
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
retired
1.7.3
1.7.2
1.7.1
1.7.0
1.6.10
1.6.9
1.6.8
1.6.7
1.6.6
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.25.0
0.24.0
0.23.1
0.23.0
0.22.0
0.21.0
0.20.0
0.19.1
0.19.0
0.18.0
0.17.0
0.16.2
0.16.1
0.16.0
0.15.2
0.15.1
0.15.0
0.14.0
0.13.0
0.12.1
0.12.0
0.11.1
0.11.0
0.10.0
0.9.1
0.9.0
0.8.0
0.7.1
0.7.0
A fast, easy to use and 100% conformant Elixir library for Google Protocol Buffers (aka protobuf)
Current section
Files
Jump to
Current section
Files
lib/protox/errors.ex
defmodule Protox.DecodingError do
@moduledoc """
This error is thrown when a data could not be decoded.
"""
defexception message: "",
binary: <<>>
@doc false
def new(binary, reason) when is_binary(binary) and is_binary(reason) do
%__MODULE__{
message: "Could not decode data (#{reason})",
binary: binary
}
end
end
defmodule Protox.EncodingError do
@moduledoc """
This error is thrown when a message could not be encoded.
"""
defexception message: "",
field: nil
@doc false
def new(field, reason) when is_atom(field) and is_binary(reason) do
%__MODULE__{
message: "Could not encode field #{inspect(field)} (#{reason})",
field: field
}
end
end
defmodule Protox.IllegalTagError do
@moduledoc """
This error is thrown when decoding data with a field which tag is 0.
"""
defexception message: "Field with illegal tag 0"
@doc false
def new() do
%__MODULE__{}
end
end
defmodule Protox.InvalidFieldAttributeError do
@moduledoc """
This error is thrown when a field is constructed with an invalid atribute.
"""
defexception message: ""
@doc false
def new(attribute, expected, got) do
%__MODULE__{
message: "Field attribute #{attribute} should be in #{inspect(expected)}, got #{inspect(got)}"
}
end
end
defmodule Protox.RequiredFieldsError do
@moduledoc """
This error is thrown when encoding or decoding a Protobuf 2 message
with unset required fields (that is, that have the value `nil`).
"""
defexception message: "",
missing_fields: []
@doc false
def new(missing_fields) do
%__MODULE__{
message: "Some required fields are not set: #{inspect(missing_fields)}",
missing_fields: missing_fields
}
end
end