Skip to content

Cannot extend core HTTPException class #3178

Description

@arnisjuraga

What I am trying to do is to extend core HTTPException class because Facebook API on HTTP requests replies with non-standart HTTP response codes and Codeigniter throws Exception on those cases.
So, I wanted to extend HTTPException class to add additional non-standart HTTP response codes (like 190 from https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling/#errorcodes )

The documentation states that, e.g.:

If you need to use a constructor in your class make sure you extend the parent constructor:

https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html#extending-core-classes

My app/Config/Autload.php config line for additional class loading:

$classmap = [
            'CodeIgniter\HTTP\Exceptions\HTTPException' => APPPATH . '/HTTPException.php',
        ];

And the class file itself located under app/HTTPException.php:

<?php

use CodeIgniter\HTTP\Exceptions\HTTPException;

class HTTPException extends \CodeIgniter\HTTP\Exceptions\HTTPException
{
    public function __construct()
    {
        dd("Loaded!"); 
    }
}

My example looks like this, but it always throws some error that
Fatal error: Cannot declare class HTTPException because the name is already in use in /app/HTTPException.php on line 7

Similar questions:

And, also, it would be enough if those codes would be possible to "ignore"?
Like problem described here: https://forum.codeigniter.com/thread-75069.html
And the extension of core classes also discussed here: #358

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions