-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from facundobatista/error-messages
Added error report support (CRAFT-103).
- Loading branch information
Showing
5 changed files
with
505 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# Copyright 2021 Canonical Ltd. | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License version 3 as published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this program; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
||
"""Error classes.""" | ||
|
||
from typing import Optional | ||
|
||
|
||
class CraftError(Exception): | ||
"""Signal a program error with a lot of information to report. | ||
:ivar message: the main message to the user, to be shown as first line (and | ||
probably only that, according to the different modes); note that in some | ||
cases the log location will be attached to this message. | ||
:ivar details: the full error details received from a third party which | ||
originated the error situation | ||
:ivar resolution: an extra line indicating to the user how the error may be | ||
fixed or avoided (to be shown together with 'message') | ||
:ivar docs_url: an URL to point the user to documentation (to be shown | ||
together with 'message') | ||
:ivar reportable: if an error report should be sent to some error-handling | ||
backend (like Sentry) | ||
:ivar retcode: the code to return when the application finishes | ||
""" | ||
|
||
def __init__( | ||
self, | ||
message: str, | ||
*, | ||
details: Optional[str] = None, | ||
resolution: Optional[str] = None, | ||
docs_url: Optional[str] = None, | ||
reportable: bool = True, | ||
retcode: int = 1, | ||
): | ||
super().__init__(message) | ||
self.details = details | ||
self.resolution = resolution | ||
self.docs_url = docs_url | ||
self.reportable = reportable | ||
self.retcode = retcode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.