-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from fauna/use-new-resp-types
Use new response types
- Loading branch information
Showing
20 changed files
with
248 additions
and
293 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
package com.fauna.exception; | ||
|
||
import com.fauna.codec.CodecProvider; | ||
import com.fauna.codec.DefaultCodecProvider; | ||
import com.fauna.codec.UTF8FaunaParser; | ||
import com.fauna.response.QueryFailure; | ||
|
||
import java.io.IOException; | ||
|
||
public class AbortException extends ServiceException { | ||
|
||
private Object abort = null; | ||
private final CodecProvider provider = DefaultCodecProvider.SINGLETON; | ||
|
||
public AbortException(QueryFailure response) { | ||
super(response); | ||
} | ||
|
||
public Object getAbort() { | ||
if (this.getResponse().getAbort().isPresent()) { | ||
return this.getResponse().getAbort().get(); | ||
public Object getAbort() throws IOException { | ||
return getAbort(Object.class); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> T getAbort(Class<T> clazz) throws IOException { | ||
if (abort != null) return (T) abort; | ||
|
||
var abStr = this.getResponse().getAbortString(); | ||
if (abStr.isPresent()) { | ||
var codec = provider.get(clazz); | ||
var parser = new UTF8FaunaParser(abStr.get()); | ||
abort = codec.decode(parser); | ||
return (T) abort; | ||
} else { | ||
throw new RuntimeException("Abort Exception missing abort data."); | ||
return null; | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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.