Skip to content

Commit

Permalink
Merge pull request #20 from StreamAMG/release/1.2.7
Browse files Browse the repository at this point in the history
SE-861 - CloudMatrixCall failure handling
  • Loading branch information
StefanoStream authored Apr 19, 2024
2 parents 83604e5 + 4aa8b30 commit 9ecd22c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ plugins {
id 'maven-publish'
}
// Versions of the library modules are matched (eg 1.0 core goes with 1.0 cloudmatrix) to prevent dependency issues
ext.SDK_VERSION_CODE = 26
ext.SDK_VERSION_NAME = "1.2.6"
ext.SDK_VERSION_CODE = 27
ext.SDK_VERSION_NAME = "1.2.7"

publishing {
publications {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ open class CloudMatrixCall {
call.enqueue(object : Callback<CloudMatrixResponse> {
override fun onFailure(call: Call<CloudMatrixResponse>, t: Throwable) {
logErrorCM("Call to CloudMatrix failed: ${t.localizedMessage}")

response(StreamAMGError(message = t.message.orEmpty(), throwable = t))
}

override fun onResponse(call: Call<CloudMatrixResponse>, response: Response<CloudMatrixResponse>) {
if (response.isSuccessful) {
val model = response.body()
model?.let {
if(model != null) {
response(model)
} else {
response(StreamAMGError(response.code(), response.message().orEmpty()))
}
} else {
response(StreamAMGError(response.code(), response.message()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.streamamg.streamapi_core.models
/**
* Model returned when a SDK call is unavailable or reports an error
*/
class StreamAMGError(val code: Int = -1, message: String)
class StreamAMGError(val code: Int = -1, message: String, throwable: Throwable? = null)
{
/**
* Returns an error code - generally HTTP - for a failed call
Expand Down

0 comments on commit 9ecd22c

Please sign in to comment.