Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scratch - model validation error handling
- Loading branch information
1 parent
acea64a
commit d45e1e3
Showing
87 changed files
with
2,367 additions
and
756 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
12.14.1 | ||
12.16.1 |
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
"name": "@dandi/common", | ||
"peerDependencies": { | ||
"luxon": "^1.4.3", | ||
"uuid": "^3.3.2" | ||
"uuid": "^7.0.0" | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as uuid from 'uuid/v4' | ||
import { v4 as uuid } from 'uuid' | ||
|
||
const UUID = new Map<string, Uuid>() | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './src/inject-decorator' | ||
export * from './src/injectable-decorator' | ||
export * from './src/optional-decorator' | ||
export * from './src/scope-decorator' |
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,12 @@ | ||
import { CreateScopeFn, getInjectableMetadata } from '@dandi/core/internal/util' | ||
|
||
export function Scope(scopeFn: CreateScopeFn): ClassDecorator & MethodDecorator { | ||
return function scopeDecorator(target: any, propertyKey?: string): void { | ||
const metaTarget = propertyKey ? target[propertyKey] : target.constructor | ||
const meta = getInjectableMetadata(metaTarget) | ||
if (meta.scopeFn && meta.scopeFn !== scopeFn) { | ||
throw Error(`Decorator Error: ${metaTarget} already has scopeFn ${scopeFn} defined`) | ||
} | ||
meta.scopeFn = scopeFn | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './src/dandi-application-error' | ||
export * from './src/dandi-injection-error' | ||
export * from './src/metadata-provider-error' | ||
export * from './src/missing-provider-error' | ||
export * from './src/provider-type-error' |
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 |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import { AppError, CUSTOM_INSPECTOR } from '@dandi/common' | ||
import { AppError, Constructor, CUSTOM_INSPECTOR } from '@dandi/common' | ||
import { InjectionToken, InjectorContext } from '@dandi/core/types' | ||
|
||
import { getTokenString } from '../../internal/util/src/injection-token-util' | ||
import { globalSymbol } from '../../src/global-symbol' | ||
|
||
const WRAP_INJECTION_ERROR = globalSymbol('WRAP_INJECTION_ERROR') | ||
|
||
export class DandiInjectionError<T> extends AppError { | ||
|
||
public static doNotWrap(errClass: Constructor<AppError>): void { | ||
Object.defineProperty(errClass.prototype, WRAP_INJECTION_ERROR, { | ||
value: false, | ||
configurable: false, | ||
}) | ||
} | ||
|
||
public static shouldWrap(err: any): boolean { | ||
return !(err instanceof DandiInjectionError) && err[WRAP_INJECTION_ERROR] !== false | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
constructor(public readonly token: InjectionToken<T>, public readonly context: InjectorContext, messageStart: string, innerError?: Error) { | ||
super(`${messageStart} ${getTokenString(token)} \nfor ${context[CUSTOM_INSPECTOR]()}`, innerError) | ||
} | ||
} | ||
DandiInjectionError.doNotWrap(DandiInjectionError) |
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,7 @@ | ||
import { AppError } from '@dandi/common' | ||
|
||
export class MetadataProviderError extends AppError { | ||
constructor(message: string, innerError?: Error) { | ||
super(message, innerError) | ||
} | ||
} |
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
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.