File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as grpc from "@grpc/grpc-js" ;
2- import { } from "@grpc/grpc-js" ;
32import { generateTestToken } from "./__utils__/helpers.js" ;
43import { Struct } from "./authzedapi/google/protobuf/struct.js" ;
54import { PreconnectServices , deadlineInterceptor } from "./util.js" ;
Original file line number Diff line number Diff line change @@ -403,13 +403,19 @@ export function NewClientWithChannelCredentials(
403403 * @returns A google.protobuf.Struct object.
404404 */
405405export function createStructFromObject ( data : JsonObject ) : ImportedPbStruct {
406- if ( data === null || typeof data !== "object" || Array . isArray ( data ) ) {
407- // Or handle this case as per library's error handling philosophy
408- throw new Error (
409- "Input data for createStructFromObject must be a non-null object." ,
410- ) ;
406+ try {
407+ return ImportedPbStruct . fromJson ( data ) ;
408+ } catch ( error ) {
409+ if (
410+ error instanceof Error &&
411+ error . message . includes ( "Unable to parse message google.protobuf.Struct from JSON" )
412+ ) {
413+ throw new Error (
414+ "Input data for createStructFromObject must be a non-null object." ,
415+ ) ;
416+ }
417+ throw error ;
411418 }
412- return ImportedPbStruct . fromJson ( data ) ;
413419}
414420
415421export * from "./authzedapi/authzed/api/v1/core.js" ;
You can’t perform that action at this time.
0 commit comments