mirror of
https://github.com/apache/superset.git
synced 2026-04-09 03:16:07 +00:00
feat: convert backend chart errors to the new error type (#9753)
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user