Skip to content

Commit

Permalink
changed some errors to more appropriate ones and removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Squared committed Apr 2, 2023
1 parent 1dab448 commit 4dba317
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/authentication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from datetime import datetime, timedelta

from fastapi import HTTPException
from src.database import Users, Sessions, IntegrityError, DoesNotExist
from src.helpers import string_in_range
from src.error import InputError
Expand Down
2 changes: 2 additions & 0 deletions src/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def generate_diagnostic_list(invoice_text: str) -> List[LintDiagnostic]:
column=violation.column,
xpath=violation.xpath,
message=violation.message,
suggestion=None,
severity="error" if violation.is_fatal else "warning"
))

Expand All @@ -122,6 +123,7 @@ def generate_diagnostic_list(invoice_text: str) -> List[LintDiagnostic]:
column=violation.column,
xpath=violation.xpath,
message=violation.message,
suggestion=None,
severity="error" if violation.is_fatal else "warning"
))

Expand Down
5 changes: 2 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import signal
from src.config import base_url, port
from src.health_check import health_check_v1
from src.report import *
Expand All @@ -7,9 +6,9 @@
from src.authentication import *
from src.type_structure import *
from src.database import clear_v1
from fastapi import Depends, FastAPI, Request, HTTPException, Security, UploadFile, File
from fastapi import Depends, FastAPI, Request,UploadFile, File
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from fastapi.responses import Response, JSONResponse, HTMLResponse, StreamingResponse
from fastapi.responses import JSONResponse, HTMLResponse, StreamingResponse
from fastapi.middleware.cors import CORSMiddleware
from io import BytesIO
import uvicorn
Expand Down
9 changes: 4 additions & 5 deletions src/report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from fastapi import HTTPException
from src.type_structure import *
from typing import Dict
from src.database import Reports, Sessions, Users
from src.type_structure import *
from src.database import Reports, Sessions
from src.generation import generate_xslt_evaluation, generate_schema_evaluation, generate_wellformedness_evaluation, generate_diagnostic_list
from peewee import DoesNotExist
from src.constants import ADMIN_TOKEN, PEPPOL_EXECUTABLE, SYNTAX_EXECUTABLE
Expand Down Expand Up @@ -61,7 +60,7 @@ def report_change_name_v2(token: str, report_id: int, new_name: str) -> Dict[Non
try:
session = Sessions.get(token=token)
except DoesNotExist:
raise ForbiddenError("Invalid token")
raise UnauthorisedError("Invalid token")
if not report.owner == session.user:
raise ForbiddenError("You do not have permission to rename this report")

Expand All @@ -86,7 +85,7 @@ def report_delete_v2(token: str, report_id: int) -> Dict[None, None]:
try:
session = Sessions.get(token=token)
except DoesNotExist:
raise ForbiddenError("Invalid token")
raise UnauthorisedError("Invalid token")

if not report.owner == session.user:
raise ForbiddenError("You do not have permission to delete this report")
Expand Down

0 comments on commit 4dba317

Please sign in to comment.