Skip to content

Commit

Permalink
Make error module available in operation helper
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-akya committed Dec 14, 2023
1 parent ca185dd commit cfc68a3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/vix/vips/image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ defmodule Vix.Vips.Image do
@spec new_from_buffer(binary(), keyword()) :: {:ok, t()} | {:error, term()}
def new_from_buffer(bin, opts \\ []) do
with {:ok, loader} <- Vix.Vips.Foreign.find_load_buffer(bin),
{:ok, {ref, _optional}} <- Vix.Vips.OperationHelper.operation_call(loader, [bin], opts) do
{:ok, {ref, _optional}} <- Vix.Vips.Operation.Helper.operation_call(loader, [bin], opts) do
{:ok, wrap_type(ref)}
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/vix/vips/mutable_operation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ defmodule Vix.Vips.MutableOperation do
Module for Vix.Vips.MutableOperation.
"""

import Vix.Vips.OperationHelper
import Vix.Vips.Operation.Helper

defmodule Error do
defexception [:message]
end
alias Vix.Vips.Operation.Error

# define typespec for enums
Enum.map(vips_enum_list(), fn {name, enum} ->
Expand Down
6 changes: 2 additions & 4 deletions lib/vix/vips/operation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ defmodule Vix.Vips.Operation do
hexdocs might *not* match for you.
"""

import Vix.Vips.OperationHelper
import Vix.Vips.Operation.Helper

defmodule Error do
defexception [:message]
end
alias Vix.Vips.Operation.Error

# define typespec for enums
Enum.map(vips_enum_list(), fn {name, enum} ->
Expand Down
5 changes: 5 additions & 0 deletions lib/vix/vips/operation/error.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
defmodule Vix.Vips.Operation.Error do
@moduledoc false

defexception [:message]
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
defmodule Vix.Vips.OperationHelper do
defmodule Vix.Vips.Operation.Helper do
@moduledoc false

alias Vix.GObject.GParamSpec
alias Vix.Nif
alias Vix.Type
alias Vix.Vips.Operation.Error

def input_to_nif_terms(args, in_pspec) do
args
Expand Down Expand Up @@ -60,7 +61,7 @@ defmodule Vix.Vips.OperationHelper do
{required, [{String.to_atom(param), value} | optional]}

true ->
raise Vix.Vips.Operation.Error, message: "Invalid operation output field: #{param}"
raise Error, message: "Invalid operation output field: #{param}"
end
end)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Vix.Vips.OperationHelperTest do
defmodule Vix.Vips.Operation.HelperTest do
use ExUnit.Case, async: true

alias Vix.Vips.Image
alias Vix.Vips.OperationHelper
alias Vix.Vips.Operation.Helper

import Vix.Support.Images

Expand All @@ -16,7 +16,7 @@ defmodule Vix.Vips.OperationHelperTest do
{:ok, im} = Image.new_from_file(img_path("puppies.jpg"))

assert {:ok, out} =
OperationHelper.operation_call(
Helper.operation_call(
"gravity",
[im, :VIPS_COMPASS_DIRECTION_CENTRE, 650, 500],
extend: :VIPS_EXTEND_COPY
Expand Down

0 comments on commit cfc68a3

Please sign in to comment.