errors.ts 520 B

1234567891011121314
  1. /** Win32 call failure with the exact API name and error code. */
  2. export class Win32Error extends Error {
  3. /** Win32 function whose checked result failed. */
  4. readonly api: string
  5. /** Exact GetLastError value or direct Win32 API error code. */
  6. readonly win32Code: number
  7. constructor(api: string, win32Code: number, detail?: string) {
  8. super(`${api} failed (Win32 ${win32Code})${detail === undefined ? '' : `: ${detail}`}`)
  9. this.name = 'Win32Error'
  10. this.api = api
  11. this.win32Code = win32Code
  12. }
  13. }