Handling exception 1) when defining Oracle function 2) When Calling Oracle function

My Oracle function below(code1) have no exception handling.
Therefore if it is called(code2) with 0, error shows.

--Code 1
CREATE OR REPLACE FUNCTION TEST2
    (P1 IN VARCHAR2)
    RETURN NUMBER AS V_VALUE NUMBER;
    BEGIN
    SELECT(
        SELECT 1/TO_NUMBER(P1)
        FROM DUAL
        )
INTO V_VALUE
FROM DUAL;
RETURN V_VALUE;
END;
/

--Code2 
SELECT TEST2('0') FROM DUAL;

Please, help to add exception handling for each 1) 2) case as below.

case 1) when defining function, how to modify code1
for function to return -1 if a system exception,
including dividing by zero happen?

case 2) Without adding exception in my Oracle funtion,
how to modify code2 for the reslut to be -1 if a system excetion, including dividing zero happens in the function?

Handling exception 1) when defining Oracle function 2) When Calling Oracle function