PHP code example of qubus / error

1. Go to this page and download the library: Download qubus/error library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qubus / error example snippets


use Qubus\Error\Error;

use function Qubus\Error\Helpers\is_error;

function get_current_user(string|int $id = null)
{
    if(null === $id) {
        return new Error('User id cannot be null.');
    }
}

$user = get_current_user('56');

if(is_error($user)) {
    // log error message or send error flash message back to the user.
}