index.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. declare module "youch" {
  2. interface YouchOptionsContract {
  3. /**
  4. * Number of lines to be displayed above the error
  5. * in the stack trace.
  6. */
  7. preLines?: number;
  8. /**
  9. * Number of lines to be displayed below the error
  10. * in the stack trace.
  11. */
  12. postLines?: number;
  13. }
  14. class Youch<Error, Request> {
  15. constructor(error: Error, request: Request, options?: YouchOptionsContract);
  16. /**
  17. * Stores the link `callback` which
  18. * will be processed when rendering
  19. * the HTML view.
  20. */
  21. addLink(callback: Function): this;
  22. /**
  23. * Returns error stack as JSON.
  24. */
  25. toJSON(): Promise<{
  26. error: {
  27. message: string;
  28. name: string;
  29. cause?: any;
  30. help?: any;
  31. status: number;
  32. frames: {
  33. file: string;
  34. filePath: string;
  35. line: number;
  36. column: number;
  37. callee: string;
  38. calleeShort: string;
  39. context: {
  40. start: number;
  41. pre: string;
  42. line: string;
  43. post: string;
  44. };
  45. isModule: boolean;
  46. isNative: boolean;
  47. isApp: boolean;
  48. }[];
  49. };
  50. }>;
  51. /**
  52. * Returns HTML representation of the error stack
  53. * by parsing the stack into frames and getting
  54. * important info out of it.
  55. */
  56. toHTML(): Promise<string>;
  57. }
  58. export default Youch;
  59. }