| 775 | |
| 776 | // Implementation |
| 777 | getSync<ValueType>( |
| 778 | keyWithPath: BindingAddress<ValueType>, |
| 779 | optionsOrSession?: ResolutionOptionsOrSession, |
| 780 | ): ValueType | undefined { |
| 781 | this.debug('Resolving binding synchronously: %s', keyWithPath); |
| 782 | |
| 783 | const valueOrPromise = this.getValueOrPromise<ValueType>( |
| 784 | keyWithPath, |
| 785 | optionsOrSession, |
| 786 | ); |
| 787 | |
| 788 | if (isPromiseLike(valueOrPromise)) { |
| 789 | throw new Error( |
| 790 | `Cannot get ${keyWithPath} synchronously: the value is a promise`, |
| 791 | ); |
| 792 | } |
| 793 | |
| 794 | return valueOrPromise; |
| 795 | } |
| 796 | |
| 797 | /** |
| 798 | * Look up a binding by key in the context and its ancestors. If no matching |