SDK API Error Handling

SDK API Error Handling Guide: OperationOutcome

Overview of OperationOutcome

The OperationOutcome is a standardized resource used to communicate the results of operations, particularly those that do not execute as expected. This resource is essential for developers as it encapsulates errors and informational messages about issues encountered during API interactions.

The OperationOutcome resource consists of one or more Issue components, each detailing a specific problem. These issues help developers understand what went wrong, why it went wrong, and how to possibly fix it. Each issue in an OperationOutcome includes the following attributes:

Using OperationOutcome in the b.well SDK

When an SDK API operation fails or encounters warnings, an OperationOutcome object is returned. This object includes all the necessary information to identify and resolve the issues. It's important for developers to check the OperationOutcome whenever an API does not return the expected result.

Business-Rule Issue Types

BUSINESS_RULE issues indicate that a request does not comply with specific business rules or constraints set by the system. When a business-rule issue is present, the details attribute of the OperationOutcome will contain additional information in a coding array. This array includes a code and a text value:

  • code: A specific error code indicating the nature of the business-rule issue.
  • text: A human-readable text intended for display to the app user, providing more context about the issue.

Developers should handle business-rule issues appropriately in their applications, ensuring that the user is informed of the issue and guided on how to correct it.

Potential Issue Types in the b.well SDK

The following tables outline potential issue types, organized by method, that could be returned via the b.well SDK.

Initialize

IssueTypeCauseAdditional Detail
REQUIREDClientKey was not provided when initializing the SDK

Authenticate

IssueTypeCauseAdditional Detail
EXCEPTIONThe SDK was not initialized prior to attempting authenticationBefore attempting to authenticate with b.well you must first successfully call initialize
VALUEInvalid Client Key
JWT could not be verified
SECURITYFailure to authenticate the user

General Errors

The following could be returned from any method after authentication has failed:

IssueTypeCauseAdditional Detail
EXCEPTIONAuthentication failed due to an invalid JWT or some other reasonThe TokenRepository contains a null access token, an authentication is required

getProfile

IssueTypeCauseAdditional Detail
NOT_FOUNDClient user/person ID was not found

updateProfile

getConsents

IssueTypeCauseAdditional Detail
EXCEPTIONConsent search failed

createConsents

IssueTypeCauseAdditional Detail
EXCEPTIONUnknown consent category passed into createConsent
Consent could not be created
REQUIREDOrganizationId was not provided when creating consent of category: PROA_ATTESTATION
VALUEOrganizationId is invalid

registerDevice

IssueTypeCauseAdditional Detail
REQUIREDPlatform or name are not present in the request
VALUEPlatform name is invalid or not recognized

getTasks

IssueTypeCauseAdditional Detail
NOT_SUPPORTEDTask sort method is not recognized
VALUEThe specified pageSize or page value is invalid

updatedTaskStatus

IssueTypeCauseAdditional Detail
INVALIDTaskId or task status is missing
Task status is not valid
NOT_FOUNDTask could not be found with provided TaskId
BUSINESS_RULEUnsupported task statusUNSUPPORTED_STATUS
The new task status provided is not supported
BUSINESS_RULETransition from current task status to new task status is not supportedUNSUPPORTED_STATE_CHANGE
For example, task status cannot be changed from COMPLETED to IN_PROGRESS

searchProviders, searchConnections

IssueTypeCauseAdditional Detail
VALUEUnsupported enum value was passed in the request
The specified pageSize or page value is invalid
EXCEPTIONAn unexpected internal error has occurred

requestConnection

IssueTypeCauseAdditional Detail
EXCEPTIONAn unexpected internal error has occurred

getDataSource

IssueTypeCauseAdditional Detail
NOT_FOUNDThe connection passed in the request does not exist

createConnection

IssueTypeCauseAdditional Detail
SECURITYThe user entered invalid credentials while making the connection
TIMEOUTThe request to the external connection service timed out
VALUEInvalid connectionId was passed in the request
EXCEPTIONAn unexpected internal error has occurred

disconnectConnection

IssueTypeCauseAdditional Detail
NOT_FOUNDUser is not connected to the connection that is being requested for disconnection

getOauthUrl

IssueTypeCauseAdditional Detail
EXCEPTIONPortal redirect URL is not configured
Could not generate authorization URL for OAuth flow
NOT_FOUNDCould not get redirect URL for the connection

get[ResourceGroups]

IssueTypeCauseAdditional Detail
VALUEUnsupported field in the request input
Non-string value assigned to string field
Non-boolean value assigned to boolean field
Non-integer value assigned to integer field
Non-date value assigned to a date field
Invalid pageSize or page
EXCEPTIONMisspelled or unsupported field in request

get[BaseResources]

IssueTypeCauseAdditional Detail
VALUEUnsupported field in the request input
Non-integer value assigned to integer field
Invalid pageSize or page

getLabKnowledge, getMedicationKnowledge

IssueTypeCauseAdditional Detail
VALUEUnsupported field in the request input
Non-ID value assigned to ID field
Non-integer value assigned to integer field
Invalid pageSize or page

getHealthSummary

IssueTypeCauseAdditional Detail
VALUEUnsupported field in the request input