[erlang-questions] Badarg error

Farruco Sanjurjo madtrick@REDACTED
Tue May 8 16:43:42 CEST 2012


Oh, I see. Thanks for pointing that : )


On 8 May 2012 09:51, Bob Ippolito <bob@REDACTED> wrote:

> In the second to last line you are declaring Frame as an integer and in
> the last line you are using it as a binary. I don't see anything obviously
> wrong other than that, but harder to read if on a phone :)
>
> On Tuesday, May 8, 2012, Farruco Sanjurjo wrote:
>
>> Hi,
>>
>> I'm getting a badarg error in this code
>>
>> from_binary(Data = <<Head:8, 0:1, PayloadLen:7, Trailing/bits>>, Acc) ->
>>   PayloadBytes=  case PayloadLen of
>>     126 ->
>>       <<ExtPayloadLen:16, _/binary>> = Trailing,
>>       2 + ExtPayloadLen;
>>     127 ->
>>       <<ExtPayloadLen:64, _/binary>> = Trailing,
>>       8 + ExtPayloadLen;
>>     _ ->
>>       %<<Payload:ExtPayloadLen/binary, Rest/binary>>
>>       PayloadLen
>>   end,
>>   FrameSize = 16 + (PayloadBytes * 8),
>>   <<Frame:FrameSize, Rest/binary>> = Data,
>>   from_binary(Rest, [decode_frame(<<Frame/binary>>) | Acc]);
>>
>> The error points to the line " FrameSize = 16 + (PayloadBytes * 8)".
>>
>> I've been struggling for a while but I can't figure out what's wrong. Any
>> suggestion?
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120508/e377d407/attachment.htm>


More information about the erlang-questions mailing list