Main Content

Access Quandl Error 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.

The history function returns errors in the matlab.net.http.ResponseMessage object. For example, suppose that you enter an invalid security name for the s 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

Access the Body 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 structure quandl_error stored in the Data 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 the code field. To view the error message text, access the message 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.'

Refer to the error message to fix your code.

See Also

|

Related Topics

External Websites