@@ -23,7 +23,7 @@ import {JSONValue} from 'proto3-json-serializer';
23
23
24
24
const protoTypePrefix = 'type.googleapis.com/' ;
25
25
const resourceInfoType = 'type.googleapis.com/google.rpc.ResourceInfo' ;
26
- const defaultResourceTypeNameForUnknownTypes = "Uknown type" ;
26
+ const defaultResourceTypeNameForUnknownTypes = 'Unknown type' ;
27
27
28
28
const numOfPartsInProtoTypeName = 2 ;
29
29
@@ -215,33 +215,42 @@ const getErrorDetails = (protobuf: any, json: JSONValue): ErrorDetails => {
215
215
return error_details ;
216
216
} ;
217
217
218
- const makeResourceInfoError = ( resourceType : string , description : string ) : JSONValue => {
218
+ const makeResourceInfoError = (
219
+ resourceType : string ,
220
+ description : string ,
221
+ ) : JSONValue => {
219
222
return {
220
223
'@type' : resourceInfoType ,
221
224
resourceType,
222
- description
223
- }
224
- }
225
+ description,
226
+ } ;
227
+ } ;
225
228
226
- const convertUnknownDetailsToResourceInfoError = ( unknownDetails : JSONValue [ ] ) => {
229
+ const convertUnknownDetailsToResourceInfoError = (
230
+ unknownDetails : JSONValue [ ] ,
231
+ ) => {
227
232
const unknownDetailsAsResourceInfoError : JSONValue [ ] = [ ] ;
228
233
for ( const unknownDetail of unknownDetails ) {
229
234
try {
230
235
let resourceType : string = defaultResourceTypeNameForUnknownTypes ;
231
- if ( typeof unknownDetail === 'object' && unknownDetail !== null && '@type' in unknownDetail ) {
236
+ if (
237
+ typeof unknownDetail === 'object' &&
238
+ unknownDetail !== null &&
239
+ '@type' in unknownDetail
240
+ ) {
232
241
const unknownType : any = unknownDetail [ '@type' ] ;
233
242
resourceType = unknownType ;
234
243
}
235
244
const description = JSON . stringify ( unknownDetail ) ;
236
245
unknownDetailsAsResourceInfoError . push (
237
- makeResourceInfoError ( resourceType , description )
246
+ makeResourceInfoError ( resourceType , description ) ,
238
247
) ;
239
248
} catch ( e ) {
240
249
// Failed convert to string, ignore it.
241
250
}
242
251
}
243
252
return unknownDetailsAsResourceInfoError ;
244
- }
253
+ } ;
245
254
246
255
export class GoogleErrorDecoder {
247
256
root : protobuf . Root ;
@@ -354,8 +363,9 @@ export class GoogleErrorDecoder {
354
363
details = errorDetails . knownDetails ;
355
364
}
356
365
if ( errorDetails . unknownDetails . length ) {
357
- const unknowDetailsAsResourceInfo = convertUnknownDetailsToResourceInfoError ( errorDetails . unknownDetails ) ;
358
- details = [ ...details , ...unknowDetailsAsResourceInfo ] ;
366
+ const unknowDetailsAsResourceInfo =
367
+ convertUnknownDetailsToResourceInfoError ( errorDetails . unknownDetails ) ;
368
+ details = [ ...details , ...unknowDetailsAsResourceInfo ] ;
359
369
}
360
370
if ( details . length ) {
361
371
json . details = details ;
0 commit comments