mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-21 05:34:42 -05:00
fix: add accurate error message when user input invalid service name or method name
This commit is contained in:
parent
4147a4c404
commit
d111db0321
@ -778,22 +778,31 @@ module.exports.grpcQuery = async (options) => {
|
|||||||
cb);
|
cb);
|
||||||
}, false, false);
|
}, false, false);
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
return grpcService[`${grpcMethod}`](JSON.parse(grpcBody), function (err, response) {
|
try {
|
||||||
const responseData = JSON.stringify(response);
|
return grpcService[`${grpcMethod}`](JSON.parse(grpcBody), function (err, response) {
|
||||||
if (err) {
|
const responseData = JSON.stringify(response);
|
||||||
return resolve({
|
if (err) {
|
||||||
code: err.code,
|
return resolve({
|
||||||
errorMessage: err.details,
|
code: err.code,
|
||||||
data: ""
|
errorMessage: err.details,
|
||||||
});
|
data: ""
|
||||||
} else {
|
});
|
||||||
log.debug("monitor:", `gRPC response: ${JSON.stringify(response)}`);
|
} else {
|
||||||
return resolve({
|
log.debug("monitor:", `gRPC response: ${JSON.stringify(response)}`);
|
||||||
code: 1,
|
return resolve({
|
||||||
errorMessage: "",
|
code: 1,
|
||||||
data: responseData
|
errorMessage: "",
|
||||||
});
|
data: responseData
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
return resolve({
|
||||||
|
code: -1,
|
||||||
|
errorMessage: `Error ${err}. Please review your gRPC configuration option. The service name must not include package name value, and the method name must follow camelCase format`,
|
||||||
|
data: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user