From a37c81802625c9b54117443a9c5efca804416340 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Wed, 27 Jul 2022 17:44:21 -0600 Subject: [PATCH 1/2] Update API.md to reflect microtime keyed errors --- contributingGuides/API.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contributingGuides/API.md b/contributingGuides/API.md index 1c0841c2d640..ce6a4167afc6 100644 --- a/contributingGuides/API.md +++ b/contributingGuides/API.md @@ -43,14 +43,16 @@ The data will automatically be sent to the user via Pusher. #### WRITE Response Errors When there is an error on a WRITE response (`jsonCode!==200`), the error must come back to the client on the HTTPS response. The error is only relevant to the client that made the request and it wouldn't make sense to send it out to all connected clients. -Error messages should be returned and stored as a String under the `error` property. If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `error`: +Error messages should be returned and stored as an object under the `errors` property, keyed by a [microtime](https://www.php.net/manual/en/function.microtime.php). If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `errors`: ```php [ 'onyxMethod' => Onyx::METHOD_MERGE, 'key' => OnyxKeys::WALLET_ADDITIONAL_DETAILS, 'value' => [ - 'error' => 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.', - 'errorCode' => 'ssnError' + 'errors' => [ + Onyx::getErrorMicroTime() => 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.', + ], + 'errorCode' => 'ssnError', ], ] ``` From 1d709b4efaf96bfaf17b8dca371118fff19186b6 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Fri, 29 Jul 2022 09:10:09 -0600 Subject: [PATCH 2/2] Updated for Neil's suggestion! --- contributingGuides/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributingGuides/API.md b/contributingGuides/API.md index ce6a4167afc6..697ac01c15cc 100644 --- a/contributingGuides/API.md +++ b/contributingGuides/API.md @@ -43,7 +43,7 @@ The data will automatically be sent to the user via Pusher. #### WRITE Response Errors When there is an error on a WRITE response (`jsonCode!==200`), the error must come back to the client on the HTTPS response. The error is only relevant to the client that made the request and it wouldn't make sense to send it out to all connected clients. -Error messages should be returned and stored as an object under the `errors` property, keyed by a [microtime](https://www.php.net/manual/en/function.microtime.php). If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `errors`: +Error messages should be returned and stored as an object under the `errors` property, keyed by an integer [microtime](https://github.com/Expensify/Web-Expensify/blob/25d056c9c531ea7f12c9bf3283ec554dd5d1d316/lib/Onyx.php#L148-L154). If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `errors`: ```php [ 'onyxMethod' => Onyx::METHOD_MERGE,