import type { IErrorResponse } from '@hizi.io/engine-sdk';

// Keep SDK failures distinguishable from validation and renderer exceptions.
export class SdkRequestError extends Error {
  readonly code: IErrorResponse['code'];
  readonly passThroughData: IErrorResponse['passThroughData'];

  constructor(error: IErrorResponse) {
    super(error.message, { cause: error });
    this.name = 'SdkRequestError';
    this.code = error.code;
    this.passThroughData = error.passThroughData;
  }
}
