-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 1303-order-page-isnt-polling-and-can-be-out-…
…of-sync
- Loading branch information
Showing
5 changed files
with
189 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/ui-components/src/lib/errors/DeploymentStepsError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { writable } from 'svelte/store'; | ||
|
||
export enum DeploymentStepsErrorCode { | ||
NO_GUI = 'Error loading GUI', | ||
NO_STRATEGY = 'No valid strategy exists at this URL', | ||
NO_SELECT_TOKENS = 'Error loading tokens', | ||
NO_TOKEN_INFO = 'Error loading token information', | ||
NO_FIELD_DEFINITIONS = 'Error loading field definitions', | ||
NO_DEPOSITS = 'Error loading deposits', | ||
NO_TOKEN_INPUTS = 'Error loading token inputs', | ||
NO_TOKEN_OUTPUTS = 'Error loading token outputs', | ||
NO_GUI_DETAILS = 'Error getting GUI details', | ||
NO_CHAIN = 'Unsupported chain ID', | ||
SERIALIZE_ERROR = 'Error serializing state', | ||
ADD_ORDER_FAILED = 'Failed to add order' | ||
} | ||
|
||
export class DeploymentStepsError extends Error { | ||
private static errorStore = writable<DeploymentStepsError | null>(null); | ||
|
||
constructor( | ||
public code: DeploymentStepsErrorCode, | ||
public details?: string | ||
) { | ||
super(code); | ||
this.name = 'DeploymentStepsError'; | ||
} | ||
|
||
static get error() { | ||
return this.errorStore; | ||
} | ||
|
||
static throwIfNull<T>(value: T | null | undefined, code: DeploymentStepsErrorCode): T { | ||
if (value === null || value === undefined) { | ||
throw new DeploymentStepsError(code); | ||
} | ||
return value; | ||
} | ||
|
||
static catch(e: unknown, code: DeploymentStepsErrorCode) { | ||
const error = | ||
e instanceof DeploymentStepsError | ||
? e | ||
: new DeploymentStepsError(code, e instanceof Error ? e.message : 'Unknown error'); | ||
this.errorStore.set(error); | ||
} | ||
|
||
static clear() { | ||
this.errorStore.set(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DeploymentStepsError'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.