Answers for "error handling"

PHP
0

error handler

function handlerError(request, response){
    response.status(500).send('opps');
}

.catch(handlerError);
Posted by: Guest on November-17-2020
0

exception handling

#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
    int a=10, b=0, c;
    // try block activates exception handling
    try 
    {
        if(b == 0)
        {
            // throw custom exception
            throw "Division by zero not possible";
            c = a/b;
        }
    }
    catch(char* ex) // catches exception
    {
        cout<<ex;
    }
    return 0;
}
Posted by: Guest on November-09-2021

Browse Popular Code Answers by Language