Skip to content

Commit cf07930

Browse files
Add FeatureError with severity level
1 parent ec036a0 commit cf07930

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/core/data_adapters/BaseAdapter.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { toArray } from 'rxjs/operators'
33
import { isStateTreeNode, getSnapshot } from 'mobx-state-tree'
44
import { ObservableCreate } from '../util/rxjs'
55
import { checkAbortSignal } from '../util'
6+
import { FeatureError } from '../util/types'
67
import { Feature } from '../util/simpleFeature'
78
import {
89
readConfObject,
@@ -169,8 +170,9 @@ export abstract class BaseFeatureDataAdapter extends BaseAdapter {
169170
checkAbortSignal(opts.signal)
170171
if (!hasData) {
171172
observer.error(
172-
new Error(
173+
new FeatureError(
173174
`refName "${region.refName}" not found. You may need to configure refName aliases.`,
175+
'info',
174176
),
175177
)
176178
} else {

packages/core/util/types/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,20 @@ export function isRetryException(exception: Error): boolean {
400400
)
401401
}
402402

403+
export class FeatureError extends Error {
404+
constructor(
405+
public message: string,
406+
public severity: 'error' | 'warning' | 'info' = 'error',
407+
) {
408+
super(message)
409+
this.name = 'FeatureError'
410+
}
411+
}
412+
413+
export function isFeatureError(error: Error): error is FeatureError {
414+
return error.name === 'FeatureError'
415+
}
416+
403417
export interface BlobLocation extends SnapshotIn<typeof MUBlobLocation> {}
404418

405419
export type FileLocation = LocalPathLocation | UriLocation | BlobLocation

plugins/linear-genome-view/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { makeStyles } from 'tss-react/mui'
44
import { observer } from 'mobx-react'
55
import { getParent } from 'mobx-state-tree'
66
import { getParentRenderProps } from '@jbrowse/core/util/tracks'
7+
import { isFeatureError } from '@jbrowse/core/util/types'
78
import RefreshIcon from '@mui/icons-material/Refresh'
89

910
const useStyles = makeStyles()(theme => ({
@@ -118,9 +119,9 @@ function BlockError({
118119
return (
119120
<div className={classes.blockMessage}>
120121
<Alert
121-
severity="error"
122+
severity={isFeatureError(error) ? error.severity : 'error'}
122123
action={
123-
reload ? (
124+
!isFeatureError(error) || error.severity === 'error' ? (
124125
<Button
125126
data-testid="reload_button"
126127
onClick={reload}

0 commit comments

Comments
 (0)