Skip to content

Commit

Permalink
pmapi: fix error messages
Browse files Browse the repository at this point in the history
add linting rule to not accidentally use [window.]name

See microsoft/TypeScript#14306 for details
  • Loading branch information
andreasgerstmayr committed Dec 1, 2020
1 parent 35ab54d commit 5699f0a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
},
"rules": {
"@typescript-eslint/no-floating-promises": "error",
"no-restricted-globals": [
"error",
"name",
"close",
"history",
"length",
"open",
"parent",
"scroll",
"stop",
"event"
],
"no-console": [
"error",
{}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
# Golang vendor dir
vendor/
vendor_jsonnet/

dist/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 3.0.1 (unreleased)

### Enhancements / Bug Fixes
- **vector, bpftrace**: fix error messages regarding missing metrics
- **test**: fix PCP Redis datasource test on 32bit architectures


Expand Down
6 changes: 3 additions & 3 deletions src/common/services/pmapi/PmApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class PmApiService {
return response.data;
} catch (error) {
if (has(error, 'data.message') && error.data.message.includes('metric has null indom')) {
throw new NoIndomError(name);
throw new NoIndomError(params.name);
} else {
throw error;
}
Expand Down Expand Up @@ -140,12 +140,12 @@ export class PmApiService {
return response.data;
} catch (error) {
if (has(error, 'data.message') && error.data.message.includes('failed to lookup metric')) {
throw new MetricNotFoundError(name);
throw new MetricNotFoundError(params.name);
} else if (
has(error, 'data.message') &&
error.data.message.includes('No permission to perform requested operation')
) {
throw new PermissionError(name);
throw new PermissionError(params.name);
} else if (has(error, 'data.message') && error.data.message.includes('Bad input')) {
return { success: false };
} else {
Expand Down

0 comments on commit 5699f0a

Please sign in to comment.