mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	add IdentifiableError.isRetryable to ensure that Identifiable Errors can still terminate a batch process
This commit is contained in:
		
							parent
							
								
									4a86ab6857
								
							
						
					
					
						commit
						3391c2414b
					
				
					 3 changed files with 16 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -520,7 +520,7 @@ export class DriveService {
 | 
			
		|||
			// If usage limit exceeded
 | 
			
		||||
			if (driveCapacity < usage + info.size) {
 | 
			
		||||
				if (isLocalUser) {
 | 
			
		||||
					throw new IdentifiableError('c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6', 'No free space.');
 | 
			
		||||
					throw new IdentifiableError('c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6', 'No free space.', true);
 | 
			
		||||
				}
 | 
			
		||||
				await this.expireOldFile(await this.usersRepository.findOneByOrFail({ id: user.id }) as MiRemoteUser, driveCapacity - info.size);
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,9 +10,15 @@ export class IdentifiableError extends Error {
 | 
			
		|||
	public message: string;
 | 
			
		||||
	public id: string;
 | 
			
		||||
 | 
			
		||||
	constructor(id: string, message?: string) {
 | 
			
		||||
	/**
 | 
			
		||||
	 * Indicates that this is a temporary error that may be cleared by retrying
 | 
			
		||||
	 */
 | 
			
		||||
	public readonly isRetryable: boolean;
 | 
			
		||||
 | 
			
		||||
	constructor(id: string, message?: string, isRetryable = false) {
 | 
			
		||||
		super(message);
 | 
			
		||||
		this.message = message ?? '';
 | 
			
		||||
		this.id = id;
 | 
			
		||||
		this.isRetryable = isRetryable;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -248,6 +248,14 @@ export class InboxProcessorService implements OnApplicationShutdown {
 | 
			
		|||
				return `skip: permanent error ${e.statusCode}`;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (e instanceof IdentifiableError && !e.isRetryable) {
 | 
			
		||||
				if (e.message) {
 | 
			
		||||
					return `skip: permanent error ${e.id}: ${e.message}`;
 | 
			
		||||
				} else {
 | 
			
		||||
					return `skip: permanent error ${e.id}`;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			throw e;
 | 
			
		||||
		}
 | 
			
		||||
		return 'ok';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue