/**
 * An operation error maintains additional information compared to a plain  {@link #Error} :
 * - The operation name
 * - A status code
 * - Extensible flags. {@see ExtendedError.FLAGS}.
  import _ from "lodash" ; import { FlaggedError } from "./flaggedError" ; export class OperationError extends Error { static FLAGS = FlaggedError . FLAGS ; public stack : string | undefined ; public readonly name : string ; param message param operation param statusCode param flags - Flags that characterize the error. See  FlaggedError . FLAGS .
        constructor ( message ? , public operation ? , public statusCode ? , public flags = 0 ) { super ( message ) ; Object . setPrototypeOf ( this , OperationError . prototype ) ; this . name = "OperationError" ; this . stack = Error ( message ) . stack ; } isQuiet ( ) { return FlaggedError . prototype . isQuiet . call ( this ) ; } isTransient ( ) { return FlaggedError . prototype . isTransient . call ( this ) ; } returns private _flagsToString ( ) { const flagArray = [ ] ; _ . mapValues ( FlaggedError . FLAGS , ( flagValue , flagName ) => { if ( ( this . flags & flagValue ) === flagValue ) { flagArray . push ( flagName ) ; } } ) ; return `${ this . flags } [${ flagArray . join ( "," ) }]` ; } toString ( ) { const extendedFieldsArray = [ ] ; if ( this . operation !== undefined ) { extendedFieldsArray . push ( this . operation ) ; } if ( this . statusCode !== undefined ) { extendedFieldsArray . push ( this . statusCode . toString ( ) ) ; } if ( this . flags ) { extendedFieldsArray . push ( this . _flagsToString . call ( this ) ) ; } let msg = this . name ; if ( extendedFieldsArray . length > 0 ) { msg += `[${ extendedFieldsArray . join ( ", " ) }]` ; } msg += `: ${ this . message }` ; if ( this . stack !== undefined ) { msg += `, stack: ${ this . stack }` ; } return msg ; } }