• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

typeorm / typeorm / 15219332477

23 May 2025 09:13PM UTC coverage: 17.216% (-59.1%) from 76.346%
15219332477

Pull #11332

github

naorpeled
cr comments - move if block
Pull Request #11332: feat: add new undefined and null behavior flags

1603 of 12759 branches covered (12.56%)

Branch coverage included in aggregate %.

0 of 31 new or added lines in 3 files covered. (0.0%)

14132 existing lines in 166 files now uncovered.

4731 of 24033 relevant lines covered (19.69%)

60.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.38
/src/error/EntityNotFoundError.ts
1
import { EntityTarget } from "../common/EntityTarget"
2
import { TypeORMError } from "./TypeORMError"
9✔
3
import { ObjectUtils } from "../util/ObjectUtils"
9✔
4
import { InstanceChecker } from "../util/InstanceChecker"
9✔
5

6
/**
7
 * Thrown when no result could be found in methods which are not allowed to return undefined or an empty set.
8
 */
9
export class EntityNotFoundError extends TypeORMError {
9✔
10
    public readonly entityClass: EntityTarget<any>
11
    public readonly criteria: any
12

13
    constructor(entityClass: EntityTarget<any>, criteria: any) {
UNCOV
14
        super()
×
15

UNCOV
16
        this.entityClass = entityClass
×
UNCOV
17
        this.criteria = criteria
×
18

UNCOV
19
        this.message =
×
20
            `Could not find any entity of type "${this.stringifyTarget(
21
                entityClass,
22
            )}" ` + `matching: ${this.stringifyCriteria(criteria)}`
23
    }
24

25
    private stringifyTarget(target: EntityTarget<any>): string {
UNCOV
26
        if (InstanceChecker.isEntitySchema(target)) {
×
27
            return target.options.name
×
UNCOV
28
        } else if (typeof target === "function") {
×
UNCOV
29
            return target.name
×
UNCOV
30
        } else if (ObjectUtils.isObject(target) && "name" in (target as any)) {
×
31
            return (target as any).name
×
32
        } else {
UNCOV
33
            return target as any
×
34
        }
35
    }
36

37
    private stringifyCriteria(criteria: any): string {
UNCOV
38
        try {
×
UNCOV
39
            return JSON.stringify(criteria, null, 4)
×
40
        } catch (e) {}
41
        return "" + criteria
×
42
    }
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc