Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created June 6, 2016 11:01
Show Gist options
  • Save olivermt/09b2c05ca342c8abfad6bd66b3e63a23 to your computer and use it in GitHub Desktop.
Save olivermt/09b2c05ca342c8abfad6bd66b3e63a23 to your computer and use it in GitHub Desktop.
[error] #PID<0.1267.0> running Core.Endpoint terminated
Server: localhost:4000 (http)
Request: PUT /api/v1/company/123/user/182/pexip_vmr/1389
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in String.Unicode.next_grapheme_size/1
(elixir) unicode/unicode.ex:32: String.Unicode.next_grapheme_size(nil)
(elixir) unicode/unicode.ex:185: String.Unicode.length/1
(core) web/models/pexip/vmr.ex:52: Core.Pexip.VMR.validate_pins/1
(core) web/service/pexip/vmr_service.ex:13: Core.Pexip.VMRService.update_vmr/2
(core) web/controllers/pexip/vmr_controller.ex:144: Core.Pexip.VMRController.do_update/4
(core) web/controllers/pexip/vmr_controller.ex:1: Core.Pexip.VMRController.action/2
(core) web/controllers/pexip/vmr_controller.ex:1: Core.Pexip.VMRController.phoenix_controller_pipeline/2
(core) lib/phoenix/router.ex:261: Core.Router.dispatch/2
defp validate_pins(changeset) do
host_pin = get_change(changeset, :pin, "")
guest_pin = get_change(changeset, :guest_pin, "")
allow_guests = get_change(changeset, :allow_guests) || false
if String.length(host_pin) > 0
and String.length(guest_pin) > 0
and String.length(host_pin) != String.length(guest_pin) do
if not(String.contains?(host_pin, "#") and String.contains?(guest_pin, "#")) do
changeset = add_error(changeset, :pin, "Must end with # when of different length than guest pin")
changeset = add_error(changeset, :guest_pin, "Must end with # when of different length than host pin")
end
end
if allow_guests and String.length(host_pin) < 1 do
changeset = add_error(changeset, :pin, "Host pin must be set if allow_guests is set")
end
if String.length(host_pin) > 0
and String.length(guest_pin) > 0
and host_pin == guest_pin do
changeset = add_error(changeset, :pin, "Cannot be identical to guest pin")
changeset = add_error(changeset, :guest_pin, "Cannot be identical to host pin")
end
changeset
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment