forked from faucetsdn/udmi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
336 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
common/src/main/java/com/google/daq/mqtt/util/ErrorMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.google.daq.mqtt.util; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Simple class for a keyed map of exceptions. | ||
*/ | ||
public class ErrorMap extends HashMap<String, Exception> { | ||
|
||
private final String description; | ||
|
||
public ErrorMap(String description) { | ||
super(); | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* Throw an exception if there's something in the map. | ||
*/ | ||
public void throwIfNotEmpty() { | ||
if (!isEmpty()) { | ||
throw asException(); | ||
} | ||
} | ||
|
||
public ErrorMapException asException() { | ||
return new ErrorMapException(); | ||
} | ||
|
||
public class ErrorMapException extends RuntimeException { | ||
|
||
ErrorMapException() { | ||
super(description); | ||
} | ||
|
||
public Map<String, Exception> getMap() { | ||
return ErrorMap.this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.