Skip to content

Commit 7676a48

Browse files
committed
add debugging section to docs
1 parent bb2eb0d commit 7676a48

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,34 @@ var client = xmlrpc.createClient('YOUR_ENDPOINT');
170170
client.methodCall('YOUR_METHOD', [new YourType(yourVariable)], yourCallback);
171171
```
172172

173+
### To Debug (client-side)
174+
175+
Error callbacks on the client are enriched with request and response
176+
information and the returned body as long as a http connection was made,
177+
to aide with request debugging. Example:
178+
179+
```javascript
180+
var client = xmlrpc.createClient({ host: 'example.com', port: 80 });
181+
client.methodCall('FAULTY_METHOD', [], function (error, value) {
182+
if (error) {
183+
console.log('error:', error);
184+
console.log('req headers:', error.req && error.req._header);
185+
console.log('res code:', error.res && error.res.statusCode);
186+
console.log('res body:', error.body);
187+
} else {
188+
console.log('value:', value);
189+
}
190+
});
191+
192+
// error: [Error: Unknown XML-RPC tag 'TITLE']
193+
// req headers: POST / HTTP/1.1
194+
// User-Agent: NodeJS XML-RPC Client
195+
// ...
196+
// res code: 200
197+
// res body: <!doctype html>
198+
// ...
199+
```
200+
173201
### To Test
174202

175203
[![Build

0 commit comments

Comments
 (0)