Skip to content

Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
Minds Backend - Engine
Minds Backend - Engine
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 241
    • Issues 241
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 32
    • Merge Requests 32
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Packages
    • Packages
    • List
    • Container Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Minds
  • Minds Backend - EngineMinds Backend - Engine
  • Issues
  • #790

Closed
Open
Opened 1 day ago by Mark Harding@markeharding
  • Report abuse
  • New issue
Report abuse New issue

(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";
}

Please solve the reCAPTCHA

We want to be sure it is you, please confirm you are not a robot.

Edited 1 day ago by Mark Harding

Related issues
0

    • Discussion 4
    • Designs 0
    • Mark Harding @markeharding changed the description 2 times within 1 minute 1 day ago

      changed the description 2 times within 1 minute

    • Juan Manuel Solaro
      Juan Manuel Solaro @juanmsolaro · 1 day ago
      Developer

      I recently used InvalidParameterException when the user select a date older than 3 months for a scheduled activity. In my understanding, this is not the correct use of exceptions, since technically, it feel just like a sort of flow control. The same occurs to me, for instance, with InsufficientBalance extends UserException. Is this really an exception or just a scenario where the endpoint should inform something to the user that the operation couldn't be completed? For me, it resembles more to a normal endpoint response.

    • Ben Hayward
      Ben Hayward @benhayward.ben · 1 day ago
      Developer

      I think @juanmsolaro has hit the nail on the head there.

    • Brian Hatchet
      Brian Hatchet :speech_balloon: @brianhatchet · 2 hours ago
      Developer

      I tend to think of exceptions in terms of HTTP status codes.

      500, something went wrong, raise an alarm in sentry because something is broken. 400, user/data/logic error, most of the 400s are situational errors and these are exceptions that should probably be reported to the user in a nice manner.

    • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
    Please register or sign in to reply

    The one place for your designs

    Upload and view the latest designs for this issue. Consistent and easy to find, so everyone is up to date.

    0 Assignees
    None
    Assign to
    None
    Epic
    None
    None
    Milestone
    None
    Assign milestone
    None
    Time tracking
    No estimate or time spent
    None
    Due date
    None
    0
    Labels
    None
    Assign labels
    • View project labels
    None
    Weight
    None
    Confidentiality
    Not confidential
    Lock issue
    Unlocked
    4
    4 participants
    user avatar
    Brian Hatchet
    user avatar
    Ben Hayward
    user avatar
    Juan Manuel Solaro
    user avatar
    Mark Harding
    Reference: minds/engine#790