-
Notifications
You must be signed in to change notification settings - Fork 30
🐛 ✨ Check #credits >= 0.0
before returning solver job outputs
#5249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bisgaard-itis
merged 25 commits into
ITISFoundation:master
from
bisgaard-itis:5236-check-positive-credits-before-returning-credits
Jan 24, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
68e0bbc
add custom error classes and handler
bisgaard-itis 7487dfc
add check that #credits > 0
bisgaard-itis b62d147
improve error message
bisgaard-itis 382f783
further improvements to exception message
bisgaard-itis 51bf6e9
allow to enable capture. This used to be possible, but seems the func…
bisgaard-itis 586f400
add initial basic unittest
bisgaard-itis 4180247
add check that payment is enabled
bisgaard-itis 0e79a59
merge master into 5236-check-positive-credits-before-returneing-credits
bisgaard-itis 0be6b5b
minor change
bisgaard-itis 490d6b1
change validation of capture mechanism setting
bisgaard-itis 709be7c
change validation of capture mechanism setting
bisgaard-itis afa6994
fix applications settigns
bisgaard-itis 19b6c32
improve applications settings check
bisgaard-itis 6f1b386
get product price
bisgaard-itis 7f7a739
merge master into 5236-check-positive-credits-before-returning-credits
bisgaard-itis 76ebf2f
fix swagger in webserver
bisgaard-itis ec067d5
test almost there
bisgaard-itis 920378b
Fix tests and custom errors
bisgaard-itis de28fa5
make pylint happy
bisgaard-itis 83d45a6
@sanderegg fix relative import
bisgaard-itis 13f7875
@pcrespov correct precheck
bisgaard-itis e6fe493
merge master into 5236-check-positive-credits-before-returning-credits
bisgaard-itis c773e35
Merge branch 'master' into 5236-check-positive-credits-before-returni…
bisgaard-itis 0b4926f
Add OEC @pcrespov
bisgaard-itis 92f135d
merge master into 5236-check-positive-credits-before-returning-credits
bisgaard-itis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
services/api-server/src/simcore_service_api_server/api/errors/custom_errors.py
This file contains hidden or 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,37 @@ | ||
import logging | ||
from urllib.request import Request | ||
|
||
from fastapi import status | ||
from servicelib.error_codes import create_error_code | ||
from starlette.responses import JSONResponse | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class CustomBaseError(Exception): | ||
pass | ||
|
||
|
||
class InsufficientCredits(CustomBaseError): | ||
pass | ||
|
||
|
||
class MissingWallet(CustomBaseError): | ||
pass | ||
|
||
|
||
async def custom_error_handler(_: Request, exc: CustomBaseError): | ||
if isinstance(exc, InsufficientCredits): | ||
return JSONResponse( | ||
status_code=status.HTTP_402_PAYMENT_REQUIRED, content=f"{exc}" | ||
) | ||
if isinstance(exc, MissingWallet): | ||
return JSONResponse( | ||
status_code=status.HTTP_424_FAILED_DEPENDENCY, content=f"{exc}" | ||
) | ||
error_code = create_error_code(exc) | ||
_logger.error("Unexpected error", extra={"error_cose": error_code}) | ||
return JSONResponse( | ||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
content=f"Unexpected server error [OEC: {error_code}]", | ||
) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.