How to recover from (MatchError) no match of right hand side value: %{}

What is the best solution if I want to try to pattern match and do something else if no match was found?

Let’s say, I want to pattern match the file like this:

        %{"file" => file} = attrs

Maybe the file field exists, maybe it doesn’t.

Is there a way to try() pattern match, else if no match do something else?

Thank you for your help!

Best,
Andreas