feat: convert backend chart errors to the new error type (#9753)

This commit is contained in:
Erik Ritter
2020-05-12 18:15:53 -07:00
committed by GitHub
parent 0e7888c659
commit 83ec7365a7
15 changed files with 175 additions and 33 deletions

View File

@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ErrorTypeEnum } from 'src/components/ErrorMessage/types';
import getClientErrorObject from 'src/utils/getClientErrorObject';
describe('getClientErrorObject()', () => {
@@ -43,6 +44,26 @@ describe('getClientErrorObject()', () => {
);
});
it('Handles backwards compatibility between old error messages and the new SIP-40 errors format', () => {
const jsonError = {
errors: [
{
errorType: ErrorTypeEnum.GENERIC_DB_ENGINE_ERROR,
extra: { engine: 'presto' },
level: 'error',
message: 'presto error: test error',
},
],
};
const jsonErrorString = JSON.stringify(jsonError);
return getClientErrorObject(new Response(jsonErrorString)).then(
errorObj => {
expect(errorObj.error).toEqual(jsonError.errors[0].message);
},
);
});
it('Handles Response that can be parsed as text', () => {
const textError = 'Hello I am a text error';