[erlang-questions] Re: try catch scope
Thu Jul 1 00:43:31 CEST 2010
On Wed, Jun 30, 2010 at 8:17 AM, Raimo Niskanen
> On Wed, Jun 30, 2010 at 07:33:39AM -0600, Wes James wrote:
>> Thanks! This is much better!
>> has_query(A) ->
>> yaws_api:parse_query(A) /= 
>> _:_ -> false
> This might be even clearer (separating the right and wrong cases):
> has_query(A) ->
> try yaws_api:parse_query(A) of
>  -> false;
> _ -> true % Were you supposed to return true for this case?
> error:_ -> false % Only cathes runtime errors, not exit/1.
Thanks. This works too. Bottom line, is I want to show the default
search page even if the parse_query call throws an error. Maybe
someone is trying to insert bad chars or such in to the URL to try to
reveal something or even hack the system, etc.
More information about the erlang-questions