-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
chore(client): use application errors instead of PlatformErrors #2337
Changes from 7 commits
fa5dca4
ac9d754
726dd2e
8cfdfd4
7c0fb81
530eceb
bc433ed
edac0c2
9457111
d27c5b1
465e6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,8 +94,8 @@ const ( | |
////////// | ||
|
||
const ( | ||
// FetchConfigFailed means we failed to fetch a config from a remote location. | ||
FetchConfigFailed ErrorCode = "ERR_FETCH_CONFIG_FAILURE" | ||
// GenericErr indicates a generic error that is not directly surfaced to the user. | ||
GenericErr ErrorCode = "ERR_GENERIC" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the |
||
|
||
// IllegalConfig indicates an invalid config to connect to a remote server. | ||
IllegalConfig ErrorCode = "ERR_ILLEGAL_CONFIG" | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -17,18 +17,14 @@ import {OperationTimedOut} from '@outline/infrastructure/timeout_promise'; | |||
|
||||
import {Clipboard} from './clipboard'; | ||||
import {EnvironmentVariables} from './environment'; | ||||
import {localizeErrorCode} from './error_localizer'; | ||||
import * as config from './outline_server_repository/config'; | ||||
import {Settings, SettingsKey} from './settings'; | ||||
import {Updater} from './updater'; | ||||
import {UrlInterceptor} from './url_interceptor'; | ||||
import {VpnInstaller} from './vpn_installer'; | ||||
import * as errors from '../model/errors'; | ||||
import * as events from '../model/events'; | ||||
import { | ||||
PlatformError, | ||||
ROUTING_SERVICE_NOT_RUNNING, | ||||
} from '../model/platform_error'; | ||||
import {PlatformError, GoErrorCode} from '../model/platform_error'; | ||||
import {Server, ServerRepository} from '../model/server'; | ||||
import {OutlineErrorReporter} from '../shared/error_reporter'; | ||||
import {ServerConnectionState, ServerListItem} from '../views/servers_view'; | ||||
|
@@ -310,18 +306,19 @@ export class App { | |||
}; | ||||
} else if (error instanceof errors.SessionConfigFetchFailed) { | ||||
toastMessage = this.localize('error-connection-configuration-fetch'); | ||||
buttonMessage = this.localize('error-details'); | ||||
buttonHandler = () => { | ||||
this.showErrorCauseDialog(error); | ||||
}; | ||||
if (error?.cause instanceof Error) { | ||||
const cause = error.cause; | ||||
buttonMessage = this.localize('error-details'); | ||||
buttonHandler = () => { | ||||
this.showErrorCauseDialog(cause); | ||||
}; | ||||
} | ||||
} else if (error instanceof errors.ProxyConnectionFailure) { | ||||
toastMessage = this.localize('error-connection-proxy'); | ||||
buttonMessage = this.localize('error-details'); | ||||
buttonHandler = () => { | ||||
this.showErrorCauseDialog(error); | ||||
}; | ||||
} else if (error instanceof errors.SessionConfigError) { | ||||
toastMessage = error.message; | ||||
} else if (error instanceof errors.SessionProviderError) { | ||||
toastMessage = error.message; | ||||
buttonMessage = this.localize('error-details'); | ||||
|
@@ -330,10 +327,6 @@ export class App { | |||
buttonHandler = () => { | ||||
this.showErrorDetailsDialog(error.details); | ||||
}; | ||||
} else if (error instanceof PlatformError) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep this. The default handler ( Also the default handler doesn't print out error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in We shouldn't be using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Where is localization of errors happening now? Are we no longer localizing these errors and just throwing a generic localized "unknown error" for them? That's a regression and is a worse user experience. We should localize the top-level user-facing error that can tell the user what went wrong (like the one suggesting to contact their service provider with details). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We localize the errors in outline-apps/client/src/www/app/app.ts Line 246 in 2e3bd3d
I'm actually removing the duplicate logic in this PR. |
||||
toastMessage = localizeErrorCode(error.code, this.localize); | ||||
buttonMessage = this.localize('error-details'); | ||||
buttonHandler = () => this.showErrorDetailsDialog(error.toString()); | ||||
} else { | ||||
const hasErrorDetails = Boolean(error.message || error.cause); | ||||
toastMessage = this.localize('error-unexpected'); | ||||
|
@@ -558,8 +551,9 @@ export class App { | |||
}); | ||||
console.error(`could not connect to server ${serverId}: ${e}`); | ||||
if ( | ||||
// TODO(fortuna): Use typed errors instead. | ||||
e instanceof PlatformError && | ||||
e.code === ROUTING_SERVICE_NOT_RUNNING | ||||
e.code === GoErrorCode.ROUTING_SERVICE_NOT_RUNNING | ||||
) { | ||||
const confirmation = | ||||
this.localize('outline-services-installation-confirmation') + | ||||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,14 +41,8 @@ export class ServerUrlInvalid extends CustomError { | |
} | ||
|
||
export class SessionConfigFetchFailed extends CustomError { | ||
constructor(message: string, options?: {cause?: Error}) { | ||
super(message, options); | ||
} | ||
} | ||
|
||
export class SessionConfigError extends CustomError { | ||
constructor(message: string, options?: {cause?: Error}) { | ||
super(message, options); | ||
constructor(cause?: Error) { | ||
super(undefined, {cause}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Maybe we can have a default human-readable |
||
} | ||
} | ||
|
||
|
@@ -63,8 +57,8 @@ export class SessionProviderError extends CustomError { | |
} | ||
|
||
export class ServerAccessKeyInvalid extends CustomError { | ||
constructor(message: string, options?: {cause?: Error}) { | ||
super(message, options); | ||
constructor(cause: Error) { | ||
super(undefined, {cause}); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to expose this error details? Especially the HTTP response code?