cube-js / cube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics
https://cube.dev
Other
17.97k stars 1.78k forks source link

@cubejs-client/core load method error does not contain HTTP error code #833

Open ryanleong opened 4 years ago

ryanleong commented 4 years ago

Describe the bug In @cubejs-client/core, when an errors occurs, there is no way to get errors the HTTP error code.

To Reproduce

  1. Make a request using @cubejs-client/core like this

    const makeQuery = async () => {
    const cubejsApi = cubejs(
    'CUBEJS-API-TOKEN',
    { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
    );
    
    try {
    const response = await cubejsApi.load(query);
    return response.chartPivot();
    } catch (error) {
    console.log(error);
    }
    }
  2. error in the catch block does not contain http error code

Expected behavior error should contain the HTTP error code

Version: ^0.15.4

Additional context

paveltiunov commented 4 years ago

@ryanleong Hey Ryan! Could you please elaborate on your use case here? How would you use it? HTTP not the only transport and not all transports have status codes.

Sandeepv68 commented 4 years ago

What if the CUBEJS-API-TOKEN gets invalidated or the api request returns a 500, how can we gracefully handle that situation without cubejs / querybuilder returning error message

vasilev-alex commented 4 years ago

Currently, this issue is outside of our roadmap. However, feel free to provide a PR and we would be happy to review it and merge.

Sandeepv68 commented 4 years ago

@vasilev-alex , if you can help me understand the part where error is captured and propagated, I will be happy to fix it for you !