Skip to content

Commit

Permalink
Merge pull request #469 from greboid/dev2
Browse files Browse the repository at this point in the history
Add a ProgramErrorAddedEvent to fix some recursive bugs.
  • Loading branch information
csmith committed Jan 12, 2015
2 parents 66340a2 + 57e2d38 commit 39f9246
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/com/dmdirc/events/FatalProgramErrorEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Fired when a fatal error is created.
*/
public class FatalProgramErrorEvent extends ProgramErrorEvent {
public class FatalProgramErrorEvent extends ProgramErrorAddedEvent {

public FatalProgramErrorEvent(final ProgramError error) {
super(error);
Expand Down
2 changes: 1 addition & 1 deletion src/com/dmdirc/events/NonFatalProgramErrorEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Fired when a non fatal program error is created.
*/
public class NonFatalProgramErrorEvent extends ProgramErrorEvent {
public class NonFatalProgramErrorEvent extends ProgramErrorAddedEvent {

public NonFatalProgramErrorEvent(final ProgramError error) {
super(error);
Expand Down
35 changes: 35 additions & 0 deletions src/com/dmdirc/events/ProgramErrorAddedEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2006-2015 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.dmdirc.events;

import com.dmdirc.logger.ProgramError;

/**
* Base class for an error event being added to the client.
*/
public abstract class ProgramErrorAddedEvent extends ProgramErrorEvent {

public ProgramErrorAddedEvent(final ProgramError error) {
super(error);
}
}
3 changes: 2 additions & 1 deletion src/com/dmdirc/logger/SentryLoggingErrorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.dmdirc.DMDircMBassador;
import com.dmdirc.config.ConfigBinder;
import com.dmdirc.config.ConfigBinding;
import com.dmdirc.events.ProgramErrorAddedEvent;
import com.dmdirc.events.ProgramErrorEvent;
import com.dmdirc.events.ProgramErrorStatusEvent;
import com.dmdirc.interfaces.config.AggregateConfigProvider;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void initialise(final AggregateConfigProvider config) {
}

@Handler
void handleErrorEvent(final ProgramErrorEvent error) {
void handleErrorEvent(final ProgramErrorAddedEvent error) {
final boolean appError = error.getError().isAppError();
if (!isValidError(error.getError().getThrowable())
|| !isValidSource(error.getError().getTrace())
Expand Down
6 changes: 3 additions & 3 deletions test/com/dmdirc/logger/SentryLoggingErrorManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import com.dmdirc.DMDircMBassador;
import com.dmdirc.config.ConfigBinder;
import com.dmdirc.events.ProgramErrorEvent;
import com.dmdirc.events.ProgramErrorAddedEvent;
import com.dmdirc.interfaces.config.AggregateConfigProvider;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -53,9 +53,9 @@ public class SentryLoggingErrorManagerTest {
@Mock private ConfigBinder configBinder;
@Mock private SentryErrorReporter sentryErrorReporter;
@Mock private ProgramError appError;
@Mock private ProgramErrorEvent appErrorEvent;
@Mock private ProgramErrorAddedEvent appErrorEvent;
@Mock private ProgramError userError;
@Mock private ProgramErrorEvent userErrorEvent;
@Mock private ProgramErrorAddedEvent userErrorEvent;
private SentryLoggingErrorManager instance;

@Before
Expand Down

0 comments on commit 39f9246

Please sign in to comment.