(discussion): The state of exceptions

  • When should exceptions be used?
  • Which exceptions should be considered friendly, and which ones system errors?
  • Which exceptions should be delivered to a user?

Minds\Core\Exceptions\ApiException

eg:

class InvalidMethod extends ApiException
{
    private $message = "This method is not allowed";
}

Minds\Core\Exceptions\UserException

Sentry should not catch these errors and the API should cleanly report the error message.

class InsufficientBalance extends UserException
{
    private $message = "You do not have enough tokens to fulfill this transaction";
}

Minds\Core\Exceptions\ApplicationException

Sentry should log, and the API may return a generic message.

class DatabaseException extends ApplicationException
{
    private $message = "The database couldn't be communicated with";
}

Minds\Core\Exceptions\Exception

Sentry should log, and the API should return a traceable error code.

class Exception extends \Exception
{
    private $message = "There was unknown error";
}
Edited by Mark Harding