Skip to content

Commit

Permalink
feat: adding proper exception for associations in the case the ids ar…
Browse files Browse the repository at this point in the history
…e wrong a non matching object is found
  • Loading branch information
cmolinatnt authored and sitole committed Nov 9, 2023
1 parent b5365be commit 3586cd0
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package org.boomevents.hubspot.domain.deals.exceptions

import org.boomevents.hubspot.domain.associations.exceptions.AssociationException
import org.boomevents.hubspot.model.mapper.Mapper
import java.math.BigInteger

data class AssociationErrorDetails(
val objectType: String,
val objectId: String
)

class AssociationNotFoundException(
associationId: BigInteger,
override val message: String = "Association '$associationId' was not found."
) : AssociationException(message)
val objectType: String,
val objectId: String
) : AssociationException("Association error: $objectType with ID $objectId was not found in Hubspot.") {
companion object {
fun fromJson(json: String): AssociationNotFoundException {
val errorDetails = Mapper.mapToObject<AssociationErrorDetails>(json)
return AssociationNotFoundException(errorDetails.objectType, errorDetails.objectId)
}
}
}

0 comments on commit 3586cd0

Please sign in to comment.