Main Content

访问QuandlError Messages

When you request historical data from Quandl®, sometimes the request returns an error instead of the historical data. Use this workflow to access Quandl error messages.

Thehistoryfunction returns errors in thematlab.net.http.ResponseMessageobject. For example, suppose that you enter an invalid security name for thesinput argument. The resulting output has this form:

d = ResponseMessage with properties: StatusLine: 'HTTP/1.1 404 Not Found' StatusCode: NotFound Header: [1×19 matlab.net.http.HeaderField] Body: [1×1 matlab.net.http.MessageBody] Completed: 0

访问theBodyproperty using dot notation.

d.Body
ans = MessageBody with properties: Data: [1×1 struct] Payload: [] ContentType: [1×1 matlab.net.http.MediaType] ContentCoding: [0×0 string]

To view the text of the error message, access the nested structurequandl_errorstored in theDataproperty.

d.Body.Data.quandl_error
ans = struct with fields: code: 'QECx02' message: 'You have submitted an incorrect Quandl code. Please check your Quandl codes and try again.'

Each error has a code and message associated with it. To view the code, access thecodefield. To view the error message text, access themessagefield. For example:

d.Body.Data.quandl_error.message
ans = 'You have submitted an incorrect Quandl code. Please check your Quandl codes and try again.'

裁判er to the error message to fix your code.

See Also

|

Related Topics

External Websites