-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify error reporting across Stack Management UIs #104235
Comments
Pinging @elastic/kibana-stack-management (Team:Stack Management) |
CC @elastic/kibana-core |
We could, but the problem with TS error handling is that, by nature, you can't really be sure what your error's shape is, and you can't restraint a So, even if we were to specialize the accepted input of type Toast = {
addError: (error: SomeSpecificError | AnotherSpecificError) => ReturnType
}
try {
explode()
} catch(e) {
// TS is awesome, e is any.
Toast.addError(e);
} Also, this would introduce bad isolation, as core's So, if I agree that the hacks around the If a consumer wants to render specific toast messages (and associated dialogs) for a specialized error type, it should be done via a custom component and using the |
Starting from TS v4.4, the
my overall 👍 However, I don't see anything bad if relax requirements for the input argument: interface ErrorLike {
message: string;
stack?: string;
}
interface RequestError extends ErrorLike { ... } |
I think this proposal should interest @elastic/kibana-app-services. The |
Problems
Incompatible SectionError component
Index Management has its own SectionError component. This component is incompatible with the ES UI Shared SectionError component, because they each expect different types of
error
to be provided to them. ES UI Shared expects theerror
object to have anerror
property, whereas Index Management expects it to havestatusText
andattributes
properties.statusText
: From what I can tell, thestatusText
property is never actually provided on theerror
object by the server, so we might be able to ignore that.attributes
: Theattributes
property is provided in three API route handlers, all within theapi/templates/
directory:register_update_route
: https://github.com/elastic/kibana/blob/master/x-pack/plugins/index_management/server/routes/api/templates/register_update_route.ts#L54register_create_route
: https://github.com/elastic/kibana/blob/master/x-pack/plugins/index_management/server/routes/api/templates/register_create_route.ts#L60register_simulate_route
: https://github.com/elastic/kibana/blob/master/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.tsCost: Aside from DX confusion (making UI migrations difficult), this impedes us from improving supportability by enhancing SectionError error reporting with any features added on the ES side (e.g. domain-specific error codes).
Resolution: We need to resolve this incompatibility and then migrate from Index Management's
SectionError
to the ES UI SharedSectionError
.Incompatibilities with ErrorToast and addError
The Toasts module's addError method accepts a global
Error
argument. This requires weird hacks to fulfill the interface's expectations.The Toasts module defines its own RequestError type, which seems like it should be defined as part of the elasticsearch-specification repo, perhaps as the ErrorResponseBase type. If that's not possible, this type should be exported and we should consume it in ES UI Shared and elsewhere in our plugins.
Cost: DX confusion makes it challenging to consistently implement error reporting and error handling in a straightforward manner. These incompatibilities also impeded us from improving supportability by enhancing
addError
error reporting with any features added on the ES side (e.g. domain-specific error codes).Resolution: We need to resolve these incompatibilities by refactoring
addError
to narrowly define the types of errors it can accept. These types of errors should be published in a centralized location and consumed by the relevant plugins.Related issues
The text was updated successfully, but these errors were encountered: