2
2
3
3
This library is currently available as a release candidate. Feel free to try it, and please give us feedback.
4
4
5
- ![ ] ( . /docs/telemetry .gif)
5
+ ![ ] ( https://coderr.io /docs/images/libraries/js/core/error .gif)
6
6
7
7
https://coderr.io
8
8
@@ -13,24 +13,24 @@ This library supports NodeJS and the browser (es6 module). There are also integr
13
13
14
14
Download this package:
15
15
16
- ``` js
16
+ ``` javascript
17
17
npm - I coderr .client
18
18
```
19
19
20
20
Add it to your application:
21
21
22
- ``` js
23
- import * as coderr from " coderr.client" ;
22
+ ``` javascript
23
+ import { err } from " coderr.client" ;
24
24
25
- coderr . configure (" https://reporting.coderr.io" , " yourAppKey" );
25
+ err . configuration . credentials (" https://reporting.coderr.io" , " yourAppKey" );
26
26
```
27
27
28
28
DOM errors will now automatically be reported (for browser-based applications).
29
29
30
30
To report errors:
31
31
32
- ``` js
33
- import * as coderr from " coderr.client" ;
32
+ ``` javascript
33
+ import { err } from " coderr.client" ;
34
34
35
35
try {
36
36
// Do something
39
39
}
40
40
catch (e) {
41
41
// You can attach any kind of data.
42
- coderr .report (e, {userId: 11 , address: { City: " Falun" }});
42
+ err .report (e, {userId: 11 , address: { City: " Falun" }});
43
43
}
44
44
```
45
45
@@ -48,43 +48,44 @@ catch (e) {
48
48
Coderr detects the environment (production/development) automatically when running in node,
49
49
for all other types of applications, specify it:
50
50
51
- ``` js
52
- import * as coderr from " coderr.client" ;
51
+ ``` javascript
52
+ import { err } from " coderr.client" ;
53
53
54
- coderr .configuration .environment = ' production' ;
54
+ err .configuration .environment = ' production' ;
55
55
```
56
56
57
57
### Application version
58
58
59
59
To see which application version an error exist, specify it:
60
60
61
- ``` js
62
- import * as coderr from " coderr.client" ;
61
+ ``` javascript
62
+ import { err } from " coderr.client" ;
63
63
64
- coderr .configuration .applicationVersion = ' 1.1.3' ;
64
+ err .configuration .applicationVersion = ' 1.1.3' ;
65
65
```
66
66
67
67
68
68
# Example, integration library
69
69
70
70
You can, for instance, install the Express package:
71
71
72
- ``` js
72
+ ``` javascript
73
73
npm - I coderr .client .expressjs
74
74
```
75
75
76
76
And then activate it:
77
77
78
- ``` js
79
- import { credentials } from " coderr.client" ;
80
- import { HttpError , errorMiddleware } from " coderr.client.expressjs" ;
78
+ ``` javascript
79
+ import { err } from " coderr.client" ;
80
+ import { activatePlugin , errorMiddleware } from " coderr.client.expressjs" ;
81
81
82
82
83
- credentials (" https://coderr.io" , " yourAppKey" , " yourSharedSecret" );
83
+ activatePlugin (err .configuration );
84
+ err .configuration .credentials (" https://coderr.io" , " yourAppKey" , " yourSharedSecret" );
84
85
```
85
86
86
87
Finally, activate the error middleware as the last middleware:
87
88
88
- ```
89
+ ``` javascript
89
90
app .use (errorMiddleware);
90
91
```
0 commit comments