File tree 4 files changed +33
-32
lines changed
4 files changed +33
-32
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,15 @@ export {
32
32
SessionFlusherLike ,
33
33
} from './session' ;
34
34
35
- /* eslint-disable deprecation/deprecation */
35
+ /* eslint-disable-next-line deprecation/deprecation */
36
36
export { Severity } from './severity' ;
37
37
export { SeverityLevel , SeverityLevels } from './severity' ;
38
38
export { Span , SpanContext } from './span' ;
39
39
export { StackFrame } from './stackframe' ;
40
40
export { Stacktrace } from './stacktrace' ;
41
+ /* eslint-disable-next-line deprecation/deprecation */
41
42
export { Status } from './status' ;
43
+ export { StatusType } from './status' ;
42
44
export {
43
45
CustomSamplingContext ,
44
46
Measurements ,
Original file line number Diff line number Diff line change 1
1
/** JSDoc
2
2
* @deprecated Use string literals - if you require type casting, cast to SeverityLevel type
3
3
*/
4
- // eslint-disable-next-line import/export
5
4
export enum Severity {
6
5
/** JSDoc */
7
6
Fatal = 'fatal' ,
Original file line number Diff line number Diff line change 1
- /** The status of an event. */
2
- // eslint-disable-next-line import/export
1
+ /** JSDoc
2
+ * @deprecated Use string literals - if you require type casting, cast to StatusType type
3
+ */
3
4
export enum Status {
4
5
/** The status could not be determined. */
5
6
Unknown = 'unknown' ,
@@ -15,31 +16,4 @@ export enum Status {
15
16
Failed = 'failed' ,
16
17
}
17
18
18
- // eslint-disable-next-line @typescript-eslint/no-namespace, import/export
19
- export namespace Status {
20
- /**
21
- * Converts a HTTP status code into a {@link Status}.
22
- *
23
- * @param code The HTTP response status code.
24
- * @returns The send status or {@link Status.Unknown}.
25
- */
26
- export function fromHttpCode ( code : number ) : Status {
27
- if ( code >= 200 && code < 300 ) {
28
- return Status . Success ;
29
- }
30
-
31
- if ( code === 429 ) {
32
- return Status . RateLimit ;
33
- }
34
-
35
- if ( code >= 400 && code < 500 ) {
36
- return Status . Invalid ;
37
- }
38
-
39
- if ( code >= 500 ) {
40
- return Status . Failed ;
41
- }
42
-
43
- return Status . Unknown ;
44
- }
45
- }
19
+ export type StatusType = 'unknown' | 'skipped' | 'rate_limit' | 'invalid' | 'failed' | 'success' ;
Original file line number Diff line number Diff line change
1
+ import { StatusType } from '@sentry/types' ;
2
+ /**
3
+ * Converts an HTTP status code to sentry status {@link StatusType}.
4
+ *
5
+ * @param code number HTTP status code
6
+ * @returns StatusType
7
+ */
8
+ export function fromHttpCode ( code : number ) : StatusType {
9
+ if ( code >= 200 && code < 300 ) {
10
+ return 'success' ;
11
+ }
12
+
13
+ if ( code === 429 ) {
14
+ return 'rate_limit' ;
15
+ }
16
+
17
+ if ( code >= 400 && code < 500 ) {
18
+ return 'invalid' ;
19
+ }
20
+
21
+ if ( code >= 500 ) {
22
+ return 'failed' ;
23
+ }
24
+
25
+ return 'unknown' ;
26
+ }
You can’t perform that action at this time.
0 commit comments