Make a custom exception

Advertisements i have a bot and sometimes i get this error: raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host=’127.0.0.1′, port=23264): Max retries exceeded with url: /lol-summoner/v1/current-summoner (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x00000170037E5B10>: Failed to establish a new connection: [WinError 10061] Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée’)) This happens but i don’t care,… Read More Make a custom exception

Why doesn't the program throw an exception despite typing the wrong type?

Advertisements Why doesn’t exception handling work in this code? It seems to me that I have implemented it well, after entering numbers of real type the application works fine, but when I enter for example random characters the program "terminates" but does not show the captured error message. In the console I get: finished with… Read More Why doesn't the program throw an exception despite typing the wrong type?

Why doesn't the program throw an exception despite typing the wrong type?

Advertisements Why doesn’t exception handling work in this code? It seems to me that I have implemented it well, after entering numbers of real type the application works fine, but when I enter for example random characters the program "terminates" but does not show the captured error message. In the console I get: finished with… Read More Why doesn't the program throw an exception despite typing the wrong type?

Handling division by zero exception in average calculation for empty lists

Advertisements I am trying to implement a function in Kotlin that returns the average of a list of numbers. The function should take a list of integers as an argument and return the average of all the elements in the list. Here’s what I have so far (with an example): fun getAverage(nums: List<Int>): Double{ return… Read More Handling division by zero exception in average calculation for empty lists

Spring: REST exceptions are caught as 403 Forbidden exception

Advertisements I created a Spring Boot Rest Api with custom JWT authentication (that I’ll change someday with Keycloak). The custom filter is this: public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtService jwtService; private final UserDetailsService userDetailsService; @Override protected void doFilterInternal( @NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull FilterChain filterChain ) throws ServletException, IOException {… Read More Spring: REST exceptions are caught as 403 Forbidden exception

What exactly happens when you create an alias of the Exception class?

Advertisements try: 0/0 except Exception as e: print(e) The above code prints division by zero as one would expect. But if we try to print without creating the alias: try: 0/0 except Exception: print(Exception) It simply prints <class ‘Exception’>. What is happening here? The as keyword is used to create an "alias". If the error… Read More What exactly happens when you create an alias of the Exception class?

SQL error or missing database (near "AUTOINCREMENT": syntax error)

Advertisements I am trying to Create 2 tables in SQLite Database. I am using sqlite-jdbc-3.32.3.2. but getting [SQLITE_ERROR] SQL error or missing database (near "AUTOINCREMENT": syntax error) package logic; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.PreparedStatement; import java.sql.Statement; public class SqliteComm{ public static void main(String[] args) { initializeDatabase(); } public static boolean… Read More SQL error or missing database (near "AUTOINCREMENT": syntax error)