访问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.
Thehistory
function returns errors in thematlab.net.http.ResponseMessage
object. For example, suppose that you enter an invalid security name for thes
input 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
访问theBody
property 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_error
stored in theData
property.
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 thecode
field. To view the error message text, access themessage
field. 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.