diff --git a/milvus/grpc/Data.ts b/milvus/grpc/Data.ts index 17e16867..acba3640 100644 --- a/milvus/grpc/Data.ts +++ b/milvus/grpc/Data.ts @@ -130,7 +130,7 @@ export class Data extends Collection { }); if (collectionInfo.status.error_code !== ErrorCode.SUCCESS) { - throw new Error(collectionInfo.status.reason); + throw collectionInfo; } // Tip: The field data sequence needs to be set same as `collectionInfo.schema.fields`. diff --git a/test/Insert.spec.ts b/test/Insert.spec.ts index 5afaabaf..bf13830d 100644 --- a/test/Insert.spec.ts +++ b/test/Insert.spec.ts @@ -141,9 +141,7 @@ describe(`Insert API`, () => { fields_data: [{}], }); } catch (error) { - expect(error.message).toEqual( - `Invalid collection name: ${errorName}. collection name can only contain numbers, letters and underscores` - ); + expect(error.status === ErrorCode.Illegal_Argument); } }); @@ -177,7 +175,6 @@ describe(`Insert API`, () => { }; const res = await milvusClient.insert(params); - console.log('xx', res); expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); }); @@ -426,7 +423,7 @@ describe(`Insert API`, () => { }); expect('a').toEqual('b'); } catch (error) { - expect(error.message).toBe('error'); + expect(error.status.reason).toBe('error'); } finally { fakeClient.closeConnection(); } diff --git a/test/Upsert.spec.ts b/test/Upsert.spec.ts index 6d0ede94..b1ddec56 100644 --- a/test/Upsert.spec.ts +++ b/test/Upsert.spec.ts @@ -140,9 +140,7 @@ describe(`Upsert API`, () => { fields_data: [{}], }); } catch (error) { - expect(error.message).toEqual( - `Invalid collection name: ${errorName}. collection name can only contain numbers, letters and underscores` - ); + expect(error.status === ErrorCode.Illegal_Argument); } }); @@ -416,7 +414,7 @@ describe(`Upsert API`, () => { }); expect('a').toEqual('b'); } catch (error) { - expect(error.message).toBe('error'); + expect(error.status.reason).toBe('error'); } finally { fakeClient.closeConnection(); }