(service: Key<any, any>)
| 1239 | hasProperty(u, ServiceNotFoundErrorTypeId) |
| 1240 | |
| 1241 | const serviceNotFoundError = (service: Key<any, any>): ServiceNotFoundError => { |
| 1242 | const error = Object.assign( |
| 1243 | new Error(`Service not found${service.key ? `: ${service.key}` : ""}`), |
| 1244 | { key: service.key } |
| 1245 | ) |
| 1246 | // Non-enumerable so the marker stays out of printed errors |
| 1247 | Object.defineProperty(error, ServiceNotFoundErrorTypeId, { value: ServiceNotFoundErrorTypeId }) |
| 1248 | if (error.stack) { |
| 1249 | const lines = error.stack.split("\n") |
| 1250 | lines.splice(1, 3) |
| 1251 | error.stack = lines.join("\n") |
| 1252 | } |
| 1253 | return error as ServiceNotFoundError |
| 1254 | } |
| 1255 | |
| 1256 | /** |
| 1257 | * Gets the service for a key safely wrapped in an `Option`. |
no test coverage detected