Skip to content
This repository was archived by the owner on Feb 10, 2023. It is now read-only.
This repository was archived by the owner on Feb 10, 2023. It is now read-only.

Error codes #25

@sagikazarmark

Description

@sagikazarmark

What's the idea behind using exception messages like 'CMP-001: Something bad happpened'?

I always found it a little bit hard to follow, and I remember we even had issues with conflicting codes. If the point is the representation, we could make the exception handler put the code before the message. Something like:

interface FuelException
{
    public function getComponentName();
}

class ComponentLoad extends \RuntimeException implements FuelException
{
    const CLASS_NOT_FOUND = 1;

    public function getComponentName()
    {
        return 'FOU';
    }
}

Then use it like:

throw new ComponentLoad("Unable to load [$fullName]: Class not found", ComponentLoad::CLASS_NOT_FOUND);

This way we would use the builtin exception code, would track the codes at one place (Exception class), would make changes easier to follow (constants) and would be possible to format the message in a custom exception handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions