Skip to content

[Feature] Display server error when loading invalid URLs #19

Description

@zonia3000

I noticed that in Viewer.jsx the source error is displayed only when it is not an array:

  } else if (!Array.isArray(sourceErrors) && sourceErrors) {
    return (
      <div className="alert alert-danger" role="alert">
        {sourceErrors.message}
      </div>
    );
  }

This implementation allows us to see the error message No source provided, but it does not account for server errors such as 404 Not Found, 401 Unauthorized, and 403 Forbidden. Indeed, in these cases, the sourceErrors variable is an array containing a single element.

I found that I can view these errors by modifying hooks.js to replace setErrors(errors) with:

setErrors(errors.length === 1 ? errors[0] : errors);

With this change, the error messages are displayed as follows:

  • 404: Node not found: v2 group
  • 401: Unexpected response status 401 Unauthorized

Changing the setErrors call is a quick fix, but I wonder if you are considering a solution that would allow to support the multiple error messages case.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions