@ooneex/exception 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,138 +1,4 @@
1
- // src/BadRequestException.ts
2
- import { HttpStatus } from "@ooneex/http-status";
1
+ import{HttpStatus as F}from"@ooneex/http-status";class p extends Error{date=new Date;status;data;native;constructor(t,r){super(t instanceof Error?t.message:t);if(this.status=r?.status||500,this.data=r?.data||{},t instanceof Error)this.native=t;this.name=this.constructor.name,this.data=Object.freeze(this.data)}stackToJson(){if(!this.stack)return null;let t=this.stack.split(`
2
+ `),r=[];for(let u=1;u<t.length;u++){let E=t[u]?.trim();if(!E)continue;let o={source:E},R=E.match(/^\s*at\s+(.+)$/);if(R){let s=R[1],y=s?.match(/^(.+?)\s+\((.+)\)$/);if(y){let e=y[1],d=y[2];if(e)o.functionName=e;let n=d?.match(/^(.+):(\d+):(\d+)$/);if(n){let x=n[1],i=n[2],w=n[3];if(x)o.fileName=x;if(i)o.lineNumber=Number.parseInt(i,10);if(w)o.columnNumber=Number.parseInt(w,10)}else if(d)o.fileName=d}else{let e=s?.match(/^(.+):(\d+):(\d+)$/);if(e){let d=e[1],n=e[2],x=e[3];if(d)o.fileName=d;if(n)o.lineNumber=Number.parseInt(n,10);if(x)o.columnNumber=Number.parseInt(x,10)}else if(s)o.functionName=s}}r.push(o)}return r}}class S extends p{constructor(t,r={}){super(t,{status:F.Code.BadRequest,data:r});this.name="BadRequestException"}}import{HttpStatus as T}from"@ooneex/http-status";class k extends p{constructor(t,r={}){super(t,{status:T.Code.MethodNotAllowed,data:r});this.name="MethodNotAllowedException"}}import{HttpStatus as q}from"@ooneex/http-status";class g extends p{constructor(t,r={}){super(t,{status:q.Code.NotFound,data:r});this.name="NotFoundException"}}import{HttpStatus as z}from"@ooneex/http-status";class C extends p{constructor(t,r={}){super(t,{status:z.Code.Unauthorized,data:r});this.name="UnauthorizedException"}}export{C as UnauthorizedException,g as NotFoundException,k as MethodNotAllowedException,p as Exception,S as BadRequestException};
3
3
 
4
- // src/Exception.ts
5
- class Exception extends Error {
6
- date = new Date;
7
- status;
8
- data;
9
- native;
10
- constructor(message, options) {
11
- super(message instanceof Error ? message.message : message);
12
- this.status = options?.status || 500;
13
- this.data = options?.data || {};
14
- if (message instanceof Error) {
15
- this.native = message;
16
- }
17
- this.name = this.constructor.name;
18
- this.data = Object.freeze(this.data);
19
- }
20
- stackToJson() {
21
- if (!this.stack) {
22
- return null;
23
- }
24
- const stackLines = this.stack.split(`
25
- `);
26
- const frames = [];
27
- for (let i = 1;i < stackLines.length; i++) {
28
- const line = stackLines[i]?.trim();
29
- if (!line)
30
- continue;
31
- const frame = {
32
- source: line
33
- };
34
- const atMatch = line.match(/^\s*at\s+(.+)$/);
35
- if (atMatch) {
36
- const content = atMatch[1];
37
- const funcWithLocationMatch = content?.match(/^(.+?)\s+\((.+)\)$/);
38
- if (funcWithLocationMatch) {
39
- const functionName = funcWithLocationMatch[1];
40
- const location = funcWithLocationMatch[2];
41
- if (functionName) {
42
- frame.functionName = functionName;
43
- }
44
- const locationMatch = location?.match(/^(.+):(\d+):(\d+)$/);
45
- if (locationMatch) {
46
- const fileName = locationMatch[1];
47
- const lineNum = locationMatch[2];
48
- const colNum = locationMatch[3];
49
- if (fileName) {
50
- frame.fileName = fileName;
51
- }
52
- if (lineNum) {
53
- frame.lineNumber = Number.parseInt(lineNum, 10);
54
- }
55
- if (colNum) {
56
- frame.columnNumber = Number.parseInt(colNum, 10);
57
- }
58
- } else if (location) {
59
- frame.fileName = location;
60
- }
61
- } else {
62
- const directLocationMatch = content?.match(/^(.+):(\d+):(\d+)$/);
63
- if (directLocationMatch) {
64
- const fileName = directLocationMatch[1];
65
- const lineNum = directLocationMatch[2];
66
- const colNum = directLocationMatch[3];
67
- if (fileName) {
68
- frame.fileName = fileName;
69
- }
70
- if (lineNum) {
71
- frame.lineNumber = Number.parseInt(lineNum, 10);
72
- }
73
- if (colNum) {
74
- frame.columnNumber = Number.parseInt(colNum, 10);
75
- }
76
- } else if (content) {
77
- frame.functionName = content;
78
- }
79
- }
80
- }
81
- frames.push(frame);
82
- }
83
- return frames;
84
- }
85
- }
86
-
87
- // src/BadRequestException.ts
88
- class BadRequestException extends Exception {
89
- constructor(message, data = {}) {
90
- super(message, {
91
- status: HttpStatus.Code.BadRequest,
92
- data
93
- });
94
- this.name = "BadRequestException";
95
- }
96
- }
97
- // src/MethodNotAllowedException.ts
98
- import { HttpStatus as HttpStatus2 } from "@ooneex/http-status";
99
- class MethodNotAllowedException extends Exception {
100
- constructor(message, data = {}) {
101
- super(message, {
102
- status: HttpStatus2.Code.MethodNotAllowed,
103
- data
104
- });
105
- this.name = "MethodNotAllowedException";
106
- }
107
- }
108
- // src/NotFoundException.ts
109
- import { HttpStatus as HttpStatus3 } from "@ooneex/http-status";
110
- class NotFoundException extends Exception {
111
- constructor(message, data = {}) {
112
- super(message, {
113
- status: HttpStatus3.Code.NotFound,
114
- data
115
- });
116
- this.name = "NotFoundException";
117
- }
118
- }
119
- // src/UnauthorizedException.ts
120
- import { HttpStatus as HttpStatus4 } from "@ooneex/http-status";
121
- class UnauthorizedException extends Exception {
122
- constructor(message, data = {}) {
123
- super(message, {
124
- status: HttpStatus4.Code.Unauthorized,
125
- data
126
- });
127
- this.name = "UnauthorizedException";
128
- }
129
- }
130
- export {
131
- UnauthorizedException,
132
- NotFoundException,
133
- MethodNotAllowedException,
134
- Exception,
135
- BadRequestException
136
- };
137
-
138
- //# debugId=61ED8CC9C66369BB64756E2164756E21
4
+ //# debugId=70B57CA4AB9AB8CA64756E2164756E21
package/dist/index.js.map CHANGED
@@ -8,7 +8,7 @@
8
8
  "import { HttpStatus } from \"@ooneex/http-status\";\nimport { Exception } from \"./Exception\";\n\nexport class NotFoundException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.NotFound,\n data,\n });\n this.name = \"NotFoundException\";\n }\n}\n",
9
9
  "import { HttpStatus } from \"@ooneex/http-status\";\nimport { Exception } from \"./Exception\";\n\nexport class UnauthorizedException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.Unauthorized,\n data,\n });\n this.name = \"UnauthorizedException\";\n }\n}\n"
10
10
  ],
11
- "mappings": ";AAAA;;;ACGO,MAAM,kBAAkB,MAA4B;AAAA,EACzC,OAAa,IAAI;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,WAAW,CAAC,SAAyB,SAAuE;AAAA,IAC1G,MAAM,mBAAmB,QAAS,QAAkB,UAAU,OAAO;AAAA,IAErE,KAAK,SAAS,SAAS,UAAU;AAAA,IACjC,KAAK,OAAO,SAAS,QAAQ,CAAC;AAAA,IAE9B,IAAI,mBAAmB,OAAO;AAAA,MAC5B,KAAK,SAAS;AAAA,IAChB;AAAA,IACA,KAAK,OAAO,KAAK,YAAY;AAAA,IAC7B,KAAK,OAAO,OAAO,OAAO,KAAK,IAAI;AAAA;AAAA,EAO9B,WAAW,GAAqC;AAAA,IACrD,IAAI,CAAC,KAAK,OAAO;AAAA,MACf,OAAO;AAAA,IACT;AAAA,IAEA,MAAM,aAAa,KAAK,MAAM,MAAM;AAAA,CAAI;AAAA,IACxC,MAAM,SAAoC,CAAC;AAAA,IAG3C,SAAS,IAAI,EAAG,IAAI,WAAW,QAAQ,KAAK;AAAA,MAC1C,MAAM,OAAO,WAAW,IAAI,KAAK;AAAA,MACjC,IAAI,CAAC;AAAA,QAAM;AAAA,MAEX,MAAM,QAAiC;AAAA,QACrC,QAAQ;AAAA,MACV;AAAA,MAOA,MAAM,UAAU,KAAK,MAAM,gBAAgB;AAAA,MAC3C,IAAI,SAAS;AAAA,QACX,MAAM,UAAU,QAAQ;AAAA,QAGxB,MAAM,wBAAwB,SAAS,MAAM,oBAAoB;AAAA,QACjE,IAAI,uBAAuB;AAAA,UACzB,MAAM,eAAe,sBAAsB;AAAA,UAC3C,MA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AAM,EAAS,CACb,OAAQ,EAAW,KAAK,iBACxB,MACF,CAAC,EACD,KAAK,KAAO,4BAEhB,CCXA,qBAAS,4BAGF,MAAM,UAA0B,CAAU,CAC/C,WAAW,CAAC,EAAiB,EAAgC,CAAC,EAAG,CAC/D,MAAM,EAAS,CACb,OAAQ,EAAW,KAAK,SACxB,MACF,CAAC,EACD,KAAK,KAAO,oBAEhB,CCXA,qBAAS,4BAGF,MAAM,UAA8B,CAAU,CACnD,WAAW,CAAC,EAAiB,EAAgC,CAAC,EAAG,CAC/D,MAAM,EAAS,CACb,OAAQ,EAAW,KAAK,aACxB,MACF,CAAC,EACD,KAAK,KAAO,wBAEhB",
12
+ "debugId": "70B57CA4AB9AB8CA64756E2164756E21",
13
13
  "names": []
14
14
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ooneex/exception",
3
3
  "description": "Type-safe exception handling with HTTP status code integration for structured error management",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -28,7 +28,7 @@
28
28
  "npm:publish": "bun publish --tolerate-republish --access public"
29
29
  },
30
30
  "dependencies": {
31
- "@ooneex/http-status": "0.0.11"
31
+ "@ooneex/http-status": "0.0.13"
32
32
  },
33
33
  "devDependencies": {},
34
34
  "keywords": [