diff --git a/src/main/java/com/eternalcode/discordapp/DiscordApp.java b/src/main/java/com/eternalcode/discordapp/DiscordApp.java index 1eba9f10..a9270cd3 100644 --- a/src/main/java/com/eternalcode/discordapp/DiscordApp.java +++ b/src/main/java/com/eternalcode/discordapp/DiscordApp.java @@ -106,6 +106,7 @@ public static void main(String... args) throws InterruptedException { levelService = new LevelService(databaseManager); } catch (SQLException exception) { + Sentry.captureException(exception); LOGGER.error("Failed to connect to database", exception); } diff --git a/src/main/java/com/eternalcode/discordapp/database/DatabaseManager.java b/src/main/java/com/eternalcode/discordapp/database/DatabaseManager.java index d1442f7d..a5bf18fc 100644 --- a/src/main/java/com/eternalcode/discordapp/database/DatabaseManager.java +++ b/src/main/java/com/eternalcode/discordapp/database/DatabaseManager.java @@ -6,6 +6,7 @@ import com.j256.ormlite.jdbc.DataSourceConnectionSource; import com.j256.ormlite.support.ConnectionSource; import com.zaxxer.hikari.HikariDataSource; +import io.sentry.Sentry; import java.io.File; import java.sql.SQLException; @@ -77,6 +78,7 @@ public Dao getDao(Class clazz) { return DaoManager.createDao(this.connectionSource, clazz); } catch (SQLException sqlException) { + Sentry.captureException(sqlException); throw new DataAccessException("Failed to create dao", sqlException); } }); diff --git a/src/main/java/com/eternalcode/discordapp/database/repository/AbstractRepository.java b/src/main/java/com/eternalcode/discordapp/database/repository/AbstractRepository.java index a1389d94..31eaff57 100644 --- a/src/main/java/com/eternalcode/discordapp/database/repository/AbstractRepository.java +++ b/src/main/java/com/eternalcode/discordapp/database/repository/AbstractRepository.java @@ -3,6 +3,7 @@ import com.eternalcode.discordapp.database.DataAccessException; import com.eternalcode.discordapp.database.DatabaseManager; import com.j256.ormlite.dao.Dao; +import io.sentry.Sentry; import panda.std.function.ThrowingFunction; import java.sql.SQLException; @@ -47,6 +48,7 @@ public CompletableFuture action(ThrowingFunction, R, SQLExcept return action.apply(dao); } catch (SQLException sqlException) { + Sentry.captureException(sqlException); throw new DataAccessException("Failed to execute database action", sqlException); } }); diff --git a/src/main/java/com/eternalcode/discordapp/leveling/LevelRepositoryImpl.java b/src/main/java/com/eternalcode/discordapp/leveling/LevelRepositoryImpl.java index 29c9df37..6dbf65a9 100644 --- a/src/main/java/com/eternalcode/discordapp/leveling/LevelRepositoryImpl.java +++ b/src/main/java/com/eternalcode/discordapp/leveling/LevelRepositoryImpl.java @@ -4,6 +4,7 @@ import com.eternalcode.discordapp.database.DatabaseManager; import com.eternalcode.discordapp.database.repository.AbstractRepository; import com.j256.ormlite.table.TableUtils; +import io.sentry.Sentry; import java.sql.SQLException; import java.util.List; @@ -20,6 +21,7 @@ public static LevelRepository create(DatabaseManager databaseManager) { TableUtils.createTableIfNotExists(databaseManager.getConnectionSource(), LevelWrapper.class); } catch (SQLException sqlException) { + Sentry.captureException(sqlException); throw new DataAccessException("Failed to create table", sqlException); } diff --git a/src/main/java/com/eternalcode/discordapp/leveling/experience/ExperienceRepositoryImpl.java b/src/main/java/com/eternalcode/discordapp/leveling/experience/ExperienceRepositoryImpl.java index 0536b784..b3c0f72b 100644 --- a/src/main/java/com/eternalcode/discordapp/leveling/experience/ExperienceRepositoryImpl.java +++ b/src/main/java/com/eternalcode/discordapp/leveling/experience/ExperienceRepositoryImpl.java @@ -4,6 +4,7 @@ import com.eternalcode.discordapp.database.DatabaseManager; import com.eternalcode.discordapp.database.repository.AbstractRepository; import com.j256.ormlite.table.TableUtils; +import io.sentry.Sentry; import java.sql.SQLException; import java.util.List; @@ -20,6 +21,7 @@ public static ExperienceRepository create(DatabaseManager databaseManager) { TableUtils.createTableIfNotExists(databaseManager.getConnectionSource(), ExperienceWrapper.class); } catch (SQLException sqlException) { + Sentry.captureException(sqlException); throw new DataAccessException("Failed to create table", sqlException); } diff --git a/src/main/java/com/eternalcode/discordapp/leveling/experience/listener/ExperienceVoiceListener.java b/src/main/java/com/eternalcode/discordapp/leveling/experience/listener/ExperienceVoiceListener.java index d0d34db8..e396e030 100644 --- a/src/main/java/com/eternalcode/discordapp/leveling/experience/listener/ExperienceVoiceListener.java +++ b/src/main/java/com/eternalcode/discordapp/leveling/experience/listener/ExperienceVoiceListener.java @@ -5,6 +5,7 @@ import com.eternalcode.discordapp.leveling.experience.ExperienceConfig; import com.eternalcode.discordapp.leveling.experience.ExperienceService; import com.eternalcode.discordapp.leveling.experience.data.UsersVoiceActivityData; +import io.sentry.Sentry; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.jetbrains.annotations.NotNull; @@ -40,6 +41,7 @@ public void onGuildVoiceUpdate(@NotNull GuildVoiceUpdateEvent event) { this.configManager.save(this.usersVoiceActivityData); } catch (Exception exception) { + Sentry.captureException(exception); throw new DataAccessException("Something went wrong while updating voice experience", exception); } } diff --git a/src/main/java/com/eternalcode/discordapp/leveling/games/GenerateImageWithCodeTask.java b/src/main/java/com/eternalcode/discordapp/leveling/games/GenerateImageWithCodeTask.java index c6a83b97..800afe8a 100644 --- a/src/main/java/com/eternalcode/discordapp/leveling/games/GenerateImageWithCodeTask.java +++ b/src/main/java/com/eternalcode/discordapp/leveling/games/GenerateImageWithCodeTask.java @@ -1,6 +1,7 @@ package com.eternalcode.discordapp.leveling.games; import com.eternalcode.discordapp.config.ConfigManager; +import io.sentry.Sentry; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.utils.FileUpload; @@ -76,6 +77,7 @@ private void sendCodeImageMessage(BufferedImage image) { ImageIO.write(image, "png", byteArrayOutputStream); } catch (IOException exception) { + Sentry.captureException(exception); exception.printStackTrace(); return; } diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java index a58df7b8..d360f624 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java @@ -2,6 +2,7 @@ import com.eternalcode.discordapp.config.AppConfig; import com.eternalcode.discordapp.config.ConfigManager; +import io.sentry.Sentry; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.User; @@ -51,6 +52,7 @@ public String createReview(Guild guild, String url, JDA jda) { return "Review created"; } catch (IOException exception) { + Sentry.captureException(exception); exception.printStackTrace(); return "Something went wrong"; } @@ -208,6 +210,7 @@ public void archiveMergedPullRequest(JDA jda) { } } catch (IOException exception) { + Sentry.captureException(exception); exception.printStackTrace(); } } diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewUtil.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewUtil.java index d9387e06..97d0cea6 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewUtil.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewUtil.java @@ -4,6 +4,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import io.sentry.Sentry; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -57,6 +58,7 @@ public static List getReviewers(GitHubPullRequest pullRequest, String gi return reviewers; } catch (IOException exception) { + Sentry.captureException(exception); exception.printStackTrace(); return Collections.emptyList(); } diff --git a/src/main/java/com/eternalcode/discordapp/review/command/child/AddChild.java b/src/main/java/com/eternalcode/discordapp/review/command/child/AddChild.java index ef2005a0..ae010681 100644 --- a/src/main/java/com/eternalcode/discordapp/review/command/child/AddChild.java +++ b/src/main/java/com/eternalcode/discordapp/review/command/child/AddChild.java @@ -5,6 +5,7 @@ import com.eternalcode.discordapp.review.GitHubReviewUser; import com.jagrosh.jdautilities.command.SlashCommand; import com.jagrosh.jdautilities.command.SlashCommandEvent; +import io.sentry.Sentry; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.OptionData; @@ -49,6 +50,7 @@ public void execute(SlashCommandEvent event) { } catch (Exception exception) { event.reply("An error occurred while adding user to the system").setEphemeral(true).queue(); + Sentry.captureException(exception); exception.printStackTrace(); } } diff --git a/src/main/java/com/eternalcode/discordapp/review/command/child/ListChild.java b/src/main/java/com/eternalcode/discordapp/review/command/child/ListChild.java index 9fc8cc58..02d0fef0 100644 --- a/src/main/java/com/eternalcode/discordapp/review/command/child/ListChild.java +++ b/src/main/java/com/eternalcode/discordapp/review/command/child/ListChild.java @@ -4,6 +4,7 @@ import com.eternalcode.discordapp.review.GitHubReviewUser; import com.jagrosh.jdautilities.command.SlashCommand; import com.jagrosh.jdautilities.command.SlashCommandEvent; +import io.sentry.Sentry; import net.dv8tion.jda.api.EmbedBuilder; import java.util.List; @@ -37,6 +38,7 @@ public void execute(SlashCommandEvent event) { } catch (Exception exception) { event.reply("An error occurred while listing the users").setEphemeral(true).queue(); + Sentry.captureException(exception); exception.printStackTrace(); } } diff --git a/src/main/java/com/eternalcode/discordapp/review/command/child/RemoveChild.java b/src/main/java/com/eternalcode/discordapp/review/command/child/RemoveChild.java index 403d24a3..eebaff6f 100644 --- a/src/main/java/com/eternalcode/discordapp/review/command/child/RemoveChild.java +++ b/src/main/java/com/eternalcode/discordapp/review/command/child/RemoveChild.java @@ -3,6 +3,7 @@ import com.eternalcode.discordapp.review.GitHubReviewService; import com.jagrosh.jdautilities.command.SlashCommand; import com.jagrosh.jdautilities.command.SlashCommandEvent; +import io.sentry.Sentry; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.OptionData; @@ -42,6 +43,7 @@ public void execute(SlashCommandEvent event) { } catch (Exception exception) { event.reply("An error occurred while removing the user from the system").setEphemeral(true).queue(); + Sentry.captureException(exception); exception.printStackTrace(); } } diff --git a/src/main/java/com/eternalcode/discordapp/user/UserRepositoryImpl.java b/src/main/java/com/eternalcode/discordapp/user/UserRepositoryImpl.java index 15a34472..e2f5452b 100644 --- a/src/main/java/com/eternalcode/discordapp/user/UserRepositoryImpl.java +++ b/src/main/java/com/eternalcode/discordapp/user/UserRepositoryImpl.java @@ -5,6 +5,7 @@ import com.eternalcode.discordapp.database.repository.AbstractRepository; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.table.TableUtils; +import io.sentry.Sentry; import java.sql.SQLException; import java.util.List; @@ -22,6 +23,7 @@ public static UserRepository create(DatabaseManager databaseManager) { TableUtils.createTableIfNotExists(databaseManager.getConnectionSource(), UserWrapper.class); } catch (SQLException sqlException) { + Sentry.captureException(sqlException); throw new DataAccessException("Failed to create table", sqlException); }