dkataskin / erlazure

Windows Azure Erlang bindings
BSD 3-Clause "New" or "Revised" License
35 stars 53 forks source link

Gracefully handle no container error #28

Open strzibny opened 5 years ago

strzibny commented 5 years ago

I am using erlazure via ex_azure and the call to put_blob fails with:

[error] GenServer #PID<0.1678.0> terminating
** (stop) bad return value: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.\nRequestId:b66001fa-d01e-005e-308e-3d06c6000000\nTime:2019-07-18T17:32:06.5364180Z</Message></Error>"
Last message (from #PID<0.93.0>): {:put_blob, 'container', 'new_file.pdf', :block_blob, <<37, 80, 68, 70, 45, 49, 46, 51, 10, 37, 255, 255, 255, 255, 10, 49, 32, 48, 32, 111, 98, 106, 10, 60, 60, 32, 47, 67, 114, 101, 97, 116, 111, 114, 32, 60, 102, 101, 102, 102, 48, 48, 53, 48, 48, ...>>, 

When I was trying to find the culprit in ex_azure I realized it simply just calls handle_call({put_blob, Container, Name, Type = block_blob, Data, Options}, _From, State) -> from erlazure.

The issue is that Azure returns the XML error, but there is no graceful failure of it. It simply makes the GenServer to fail... I would probably except that an error tuple with the error message is returned.

dotdotdotpaul commented 4 years ago

Running into this too -- can't seem to catch/rescue from the failure in my caller, either. 😛