-
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.
feat: adding proper exception for associations in the case the ids ar…
…e wrong a non matching object is found
- Loading branch information
1 parent
b5365be
commit 3586cd0
Showing
1 changed file
with
16 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 16 additions & 3 deletions
19
...lin/org/boomevents/hubspot/domain/associations/exceptions/AssociationNotFoundException.kt
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,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) | ||
} | ||
} | ||
} |