master #475
| @@ -16,8 +16,8 @@ from werkzeug.exceptions import NotFound | ||||
|  | ||||
| from bot_api.configuration.api_settings import ApiSettings | ||||
| from bot_api.configuration.authentication_settings import AuthenticationSettings | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.logging.api_logger import ApiLogger | ||||
| from bot_api.model.error_dto import ErrorDTO | ||||
| from bot_api.route.route import Route | ||||
|   | ||||
| @@ -16,7 +16,7 @@ from bot_api.api import Api | ||||
| from bot_api.configuration.discord_authentication_settings import ( | ||||
|     DiscordAuthenticationSettings, | ||||
| ) | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.logging.api_logger import ApiLogger | ||||
| from bot_api.model.auth_user_dto import AuthUserDTO | ||||
| from bot_api.route.route import Route | ||||
|   | ||||
| @@ -1,26 +0,0 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| """ | ||||
| bot sh-edraft.de Discord bot | ||||
| ~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| Discord bot for customers of sh-edraft.de | ||||
|  | ||||
| :copyright: (c) 2022 - 2023 sh-edraft.de | ||||
| :license: MIT, see LICENSE for more details. | ||||
|  | ||||
| """ | ||||
|  | ||||
| __title__ = "bot_api.exception" | ||||
| __author__ = "Sven Heidemann" | ||||
| __license__ = "MIT" | ||||
| __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" | ||||
| __version__ = "1.2.6" | ||||
|  | ||||
| from collections import namedtuple | ||||
|  | ||||
|  | ||||
| # imports: | ||||
|  | ||||
| VersionInfo = namedtuple("VersionInfo", "major minor micro") | ||||
| version_info = VersionInfo(major="1", minor="2", micro="6") | ||||
| @@ -1,10 +1,7 @@ | ||||
| import traceback | ||||
| from typing import Optional | ||||
|  | ||||
| from cpl_core.console import Console | ||||
|  | ||||
| from bot_api.abc.dto_abc import DtoABC | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
|  | ||||
|  | ||||
| class ErrorDTO(DtoABC): | ||||
|   | ||||
| @@ -8,8 +8,8 @@ from flask import request, jsonify | ||||
| from flask_cors import cross_origin | ||||
|  | ||||
| from bot_api.abc.auth_service_abc import AuthServiceABC | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.model.error_dto import ErrorDTO | ||||
| from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC | ||||
| from bot_data.model.auth_role_enum import AuthRoleEnum | ||||
|   | ||||
| @@ -18,8 +18,8 @@ from flask import request | ||||
| from bot_api.abc.auth_service_abc import AuthServiceABC | ||||
| from bot_api.configuration.authentication_settings import AuthenticationSettings | ||||
| from bot_api.configuration.frontend_settings import FrontendSettings | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria | ||||
| from bot_api.logging.api_logger import ApiLogger | ||||
| from bot_api.model.auth_user_dto import AuthUserDTO | ||||
|   | ||||
| @@ -4,8 +4,8 @@ from cpl_discord.service import DiscordBotServiceABC | ||||
| from cpl_query.extension import List | ||||
|  | ||||
| from bot_api.abc.auth_service_abc import AuthServiceABC | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.filter.discord.server_select_criteria import ServerSelectCriteria | ||||
| from bot_api.model.discord.server_dto import ServerDTO | ||||
| from bot_api.model.discord.server_filtered_result_dto import ServerFilteredResultDTO | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| 
 | ||||
| 
 | ||||
| class ServiceException(Exception): | ||||
| @@ -1,8 +1,11 @@ | ||||
| import time | ||||
| import uuid | ||||
|  | ||||
| from cpl_core.database import DatabaseSettings | ||||
| from cpl_core.database.context import DatabaseContext | ||||
|  | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_core.logging.database_logger import DatabaseLogger | ||||
|  | ||||
|  | ||||
| @@ -34,7 +37,12 @@ class DBContext(DatabaseContext): | ||||
|             return super(DBContext, self).select(statement) | ||||
|         except Exception as e: | ||||
|             if self._fails >= 3: | ||||
|                 self._logger.fatal(__name__, f"Database error caused by {statement}", e) | ||||
|                 self._logger.error(__name__, f"Database error caused by {statement}", e) | ||||
|                 uid = uuid.uuid4() | ||||
|                 raise ServiceException( | ||||
|                     ServiceErrorCode.Unknown, | ||||
|                     f"Query failed three times with {type(e).__name__}. Contact an admin and give them the UID: {uid}", | ||||
|                 ) | ||||
|  | ||||
|             self._logger.error(__name__, f"Database error caused by {statement}", e) | ||||
|             self._fails += 1 | ||||
|   | ||||
| @@ -7,8 +7,8 @@ from cpl_core.type import T | ||||
| from cpl_discord.service import DiscordBotServiceABC | ||||
| from cpl_query.extension import List | ||||
|  | ||||
| from bot_api.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_api.exception.service_exception import ServiceException | ||||
| from bot_core.exception.service_error_code_enum import ServiceErrorCode | ||||
| from bot_core.exception.service_exception import ServiceException | ||||
| from bot_api.route.route import Route | ||||
| from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum | ||||
| from bot_core.environment_variables import MAINTENANCE | ||||
|   | ||||
| @@ -1,19 +1,15 @@ | ||||
| import { Component, OnDestroy, OnInit } from "@angular/core"; | ||||
| import { FormBuilder, FormControl, FormGroup } from "@angular/forms"; | ||||
| import { Router } from "@angular/router"; | ||||
| import { TranslateService } from "@ngx-translate/core"; | ||||
| import { debounceTime, Subject, throwError } from "rxjs"; | ||||
| import { ConfirmationDialogService } from "src/app/services/confirmation-dialog/confirmation-dialog.service"; | ||||
| import { DataService } from "src/app/services/data/data.service"; | ||||
| import { SpinnerService } from "src/app/services/spinner/spinner.service"; | ||||
| import { ToastService } from "src/app/services/toast/toast.service"; | ||||
| import { Server, ServerFilter } from "../../../../../models/data/server.model"; | ||||
| import { catchError, takeUntil } from "rxjs/operators"; | ||||
| import { Queries } from "../../../../../models/graphql/queries.model"; | ||||
| import { Page } from "../../../../../models/graphql/filter/page.model"; | ||||
| import { Sort } from "../../../../../models/graphql/filter/sort.model"; | ||||
| import { Query } from "../../../../../models/graphql/query.model"; | ||||
| import { SidebarService } from "../../../../../services/sidebar/sidebar.service"; | ||||
| import { ServerService } from "../../../../../services/server.service"; | ||||
|  | ||||
| @Component({ | ||||
| @@ -47,7 +43,7 @@ export class DashboardComponent implements OnInit, OnDestroy { | ||||
|     private spinnerService: SpinnerService, | ||||
|     private fb: FormBuilder, | ||||
|     private router: Router, | ||||
|     private serverService: ServerService, | ||||
|     private serverService: ServerService | ||||
|   ) { | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -11,13 +11,14 @@ export class ErrorHandlerService implements ErrorHandler { | ||||
|  | ||||
|   constructor( | ||||
|     private auth: AuthService, | ||||
|     private toast: ToastService, | ||||
|   ) { } | ||||
|     private toast: ToastService | ||||
|   ) { | ||||
|   } | ||||
|  | ||||
|   handleError(error: HttpErrorResponse): Observable<never> { | ||||
|     if (error && error.error) { | ||||
|       let message = 'Unbekannter Fehler'; | ||||
|       let header = 'Fehler'; | ||||
|       let message = "Unbekannter Fehler"; | ||||
|       let header = "Fehler"; | ||||
|       const errorDto: ErrorDTO = error.error; | ||||
|  | ||||
|       if (errorDto.errorCode === ServiceErrorCode.Unauthorized) { | ||||
| @@ -26,7 +27,7 @@ export class ErrorHandlerService implements ErrorHandler { | ||||
|       } | ||||
|  | ||||
|       if (errorDto.errorCode !== undefined) { | ||||
|         header = 'Fehlercode: ' + errorDto.errorCode; | ||||
|         header = "Fehlercode: " + errorDto.errorCode; | ||||
|       } | ||||
|  | ||||
|       if (errorDto.message) { | ||||
| @@ -37,6 +38,7 @@ export class ErrorHandlerService implements ErrorHandler { | ||||
|  | ||||
|       this.toast.error(header, message); | ||||
|     } else { | ||||
|       this.toast.error("ERROR", error.message); | ||||
|       console.error(error.message); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user