/**
 * Error thrown when saved object migrations encounter a transformation error.
 * Transformation errors happen when a transform function throws an error for an unsanitized saved object
 */ export class TransformSavedObjectDocumentError extends Error { constructor ( public readonly originalError , public readonly version ) { super ( `Migration function for version ${ version } threw an error` ) ; appendCauseStack ( this , originalError ) ; } } const appendCauseStack = ( error , cause ) => { error . stack = ( error . stack ?? '' ) + `\nCaused by:\n${ cause . stack ?? cause . message }` ; } ;