mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 06:33:28 +00:00
Avoid Sentry reporting of selected common "expected" errors
Change-type: patch
This commit is contained in:
parent
d2df2c7b60
commit
5a80654305
@ -17,8 +17,9 @@ limitations under the License.
|
||||
import { stripIndent } from 'common-tags';
|
||||
import * as _ from 'lodash';
|
||||
import * as os from 'os';
|
||||
import { TypedError } from 'typed-error';
|
||||
|
||||
export class ExpectedError extends Error {}
|
||||
export class ExpectedError extends TypedError {}
|
||||
|
||||
export class NotLoggedInError extends ExpectedError {}
|
||||
|
||||
@ -115,7 +116,17 @@ export async function handleError(error: any) {
|
||||
}
|
||||
printErrorMessage(message.join('\n'));
|
||||
|
||||
if (error instanceof ExpectedError) {
|
||||
const expectedErrorREs = [
|
||||
/^BalenaApplicationNotFound:/, // balena-sdk
|
||||
/^BalenaDeviceNotFound:/, // balena-sdk
|
||||
/^Missing \w+$/, // Capitano's command line parsing error
|
||||
/^Unexpected arguments?:/, // oclif's command line parsing error
|
||||
];
|
||||
|
||||
if (
|
||||
error instanceof ExpectedError ||
|
||||
expectedErrorREs.some(re => re.test(message[0]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ import { RegistrySecrets } from 'resin-multibuild';
|
||||
import * as Stream from 'stream';
|
||||
import streamToPromise = require('stream-to-promise');
|
||||
import { Pack } from 'tar-stream';
|
||||
import { TypedError } from 'typed-error';
|
||||
import Logger = require('./logger');
|
||||
|
||||
import { ExpectedError } from '../errors';
|
||||
import { exitWithExpectedError } from '../utils/patterns';
|
||||
import { tarDirectory } from './compose';
|
||||
import { getVisuals } from './lazy';
|
||||
import Logger = require('./logger');
|
||||
|
||||
const globalLogger = Logger.getLogger();
|
||||
|
||||
@ -77,7 +77,7 @@ interface HeadlessBuilderMessage {
|
||||
releaseId?: number;
|
||||
}
|
||||
|
||||
export class RemoteBuildFailedError extends TypedError {
|
||||
export class RemoteBuildFailedError extends ExpectedError {
|
||||
public constructor(message = 'Remote build failed') {
|
||||
super(message);
|
||||
}
|
||||
@ -138,10 +138,10 @@ export async function startRemoteBuild(build: RemoteBuild): Promise<void> {
|
||||
stream.on('end', resolve);
|
||||
stream.on('error', reject);
|
||||
}).then(() => {
|
||||
globalLogger.outputDeferredMessages();
|
||||
if (build.hadError) {
|
||||
throw new RemoteBuildFailedError();
|
||||
}
|
||||
globalLogger.outputDeferredMessages();
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user