Private
Public Access
1
0

unified all notokenerrors

This commit is contained in:
Sander Roosendaal
2018-06-26 12:20:24 +02:00
parent 0152c8d20b
commit 586cc2b209
3 changed files with 20 additions and 72 deletions

View File

@@ -50,32 +50,8 @@ from rowsandall_app.settings import (
#baseurl = 'https://polaraccesslink.com/v3-example'
baseurl = 'https://polaraccesslink.com/v3'
# Custom exception handler, returns a 401 HTTP message
# with exception details in the json data
def custom_exception_handler(exc,message):
response = {
"errors": [
{
"code": str(exc),
"detail": message,
}
]
}
res = HttpResponse(message)
res.status_code = 401
res.json = json.dumps(response)
return res
# Custom error class - to raise a NoTokenError
class PolarNoTokenError(Exception):
def __init__(self,value):
self.value=value
def __str__(self):
return repr(self.value)
from utils import NoTokenError, custom_exception_handler
# Exchange access code for long-lived access token