-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom exceptions, reworked Result API - raising exception righ…
…t away
- Loading branch information
Showing
14 changed files
with
127 additions
and
145 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
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
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,26 @@ | ||
|
||
|
||
class ArcaException(Exception): | ||
pass | ||
|
||
|
||
class ArcaMisconfigured(ArcaException): | ||
pass | ||
|
||
|
||
class TaskMisconfigured(ValueError, ArcaException): | ||
pass | ||
|
||
|
||
class BuildError(ArcaException): | ||
|
||
def __init__(self, *args, extra_info=None, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.extra_info = extra_info | ||
|
||
|
||
class PushToRegistryError(ArcaException): | ||
|
||
def __init__(self, *args, full_output=None, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.full_output = full_output |
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 |
---|---|---|
@@ -1,23 +1,14 @@ | ||
from typing import Dict, Union, Any | ||
|
||
from arca.exceptions import BuildError | ||
|
||
|
||
class Result: | ||
|
||
def __init__(self, result: Dict[str, Union[bool, str, Any]]) -> None: | ||
self.success = result.get("success") | ||
self._result = result.get("result") | ||
self._error = result.get("error") | ||
|
||
@property | ||
def error(self) -> str: | ||
if self.success: | ||
raise AttributeError("The task succeeded, there's no error") | ||
|
||
return self._error | ||
|
||
@property | ||
def result(self) -> Any: | ||
if not self.success: | ||
raise AttributeError("The task did not succeed, there's not result") | ||
if not result.get("success"): | ||
raise BuildError("The build failed", extra_info={ | ||
"traceback": result.get("error") | ||
}) | ||
|
||
return self._result | ||
self.output = result.get("result") |
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
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.