Error response enhancements, CoreID auth client backend
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Base type for a canonical definition.
|
||||
*/
|
||||
import {Canon} from './Canon'
|
||||
import {universalPath, UniversalPath, ErrorWithContext} from '../util'
|
||||
import {universalPath, UniversalPath, ErrorWithContext, Safe} from '../util'
|
||||
import {Logging} from './Logging'
|
||||
import {Inject} from '../di'
|
||||
import * as nodePath from 'path'
|
||||
@@ -192,6 +192,18 @@ export abstract class Canonical<T> extends Unit {
|
||||
return this.loadedItems[key]
|
||||
}
|
||||
|
||||
/** Get a canonical item by key as a Safe value. */
|
||||
public safe(key: string): Safe {
|
||||
return (new Safe(this.get(key))).onError((message, value) => {
|
||||
throw new ErrorWithContext(`Invalid canonical value: ${message}`, {
|
||||
canonicalKey: key,
|
||||
canonicalItems: this.canonicalItems,
|
||||
value,
|
||||
message,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a namespace resolver with the canonical unit.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user