On Sun, Aug 16, 2015 at 4:51 PM, Jeffrey Sarnoff
<[email protected]> wrote:
> not throw -- raise
>
> On Sun, Aug 16, 2015 at 2:59 PM, Jeffrey Sarnoff <[email protected]>
> wrote:
>>
>> Writing customized exception, I want to include the name of a var used as
>> an argument in the caller of the function generating the exception.
>> I saw similiar access from a function once, and am unable to re-locate
>> that.  thanks.

You cannot do that. If you really need the local variable name, use a
macro the transform the code to pass in the name explicitly.

>>
>> function caller(potato::Int)
>>     called(potato)
>> end
>>
>> function called(tally::Int)
>>    if tally>16
>>      throw(TooMany, "$(tally) is way too many")
>>   elseif tally>4
>>      throw(TooMany, "$(tally) is a few more than expected.")
>>   end
>>   true
>> end
>>
>> caller(22)
>>   Error.. "caller(potato=22) is way too many" .. in (the usual)
>>
>>
>>
>>
>

Reply via email to